BestGpu.h is now the place to #define CPUONLY in source code if needed (which you would do when compiling from Visual Studio. You can also define it on the compiler command line, which you would do when compiling from an explicit makefile);

references to CUDA libs moved from BestGpu.h to the .cpp, which is will soon be moved into the CNTKMathCUDA project and thus not get compiled if no CUDA SDK is installed;
no-CUDA implementation of DeviceFromConfig() moved from BestGpu.cpp to NoGPU.cpp;
removed several no-longer-needed CUDA references from project files--two referenced-lib settings are now again identical between Debug and Release, they were inconsistent before
This commit is contained in:
Frank Seide 2014-11-04 09:10:32 -08:00
Родитель 11a7c05c23
Коммит beb24799fe
7 изменённых файлов: 407 добавлений и 402 удалений

Просмотреть файл

@ -7,18 +7,16 @@
#define _CRT_SECURE_NO_WARNINGS // "secure" CRT not available on all platforms --add this at the top of all CPP files that give "function or variable may be unsafe" warnings
#include "BestGpu.h"
#ifndef CPUONLY
#pragma comment (lib, "cudart.lib")
#pragma comment (lib, "nvml.lib")
#include <cuda_runtime.h>
#include <nvml.h>
#include <vector>
#endif
#include "CommonMatrix.h" // for CPUDEVICE and AUTOPLACEMATRIX
#ifdef CPUONLY // #define this to disable GPUs
namespace Microsoft { namespace MSR { namespace CNTK {
short DeviceFromConfig(const ConfigParameters& /*config*/)
{
return CPUDEVICE;
}
}}}
#else // CPUONLY
#ifndef CPUONLY // #define this to disable GPUs
// CUDA-C includes
#include <cuda.h>

Просмотреть файл

@ -6,12 +6,8 @@
#pragma once
#ifndef CPUONLY
#pragma comment (lib, "cudart.lib")
#include <cuda_runtime.h>
#include <nvml.h>
#include <vector>
#endif
// #define CPUONLY // #define this to build without GPU support nor needing the SDK installed
#include "commandArgUtil.h"
namespace Microsoft { namespace MSR { namespace CNTK {

Просмотреть файл

@ -71,7 +71,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>cudart.lib;Delayimp.lib;nvml.lib;cntkMath.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Delayimp.lib;cntkMath.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\;..\..\math\$(Platform)\$(Configuration);..\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<DelayLoadDLLs>CNTKMath.dll;nvml.dll</DelayLoadDLLs>
</Link>
@ -96,7 +96,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Delayimp.lib;nvml.lib;cudart.lib;cntkMath.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Delayimp.lib;cntkMath.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\math\$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
<Profile>true</Profile>
<DelayLoadDLLs>CNTKMath.dll;nvml.dll</DelayLoadDLLs>

Просмотреть файл

@ -19,6 +19,11 @@
#include "GPUSparseMatrix.h"
#include <iostream> // for cout
#pragma comment (lib, "cudart.lib") // instruct linker to reference these libs
#pragma comment (lib, "cublas.lib")
#pragma comment (lib, "cusparse.lib")
#pragma comment (lib, "curand.lib")
#pragma warning (disable: 4267) // conversion from 'size_t' to 'unsigned int'; happens in CUDA <<<a,b>>> syntax if a and b are size_t
#pragma warning (disable: 4127) // conditional expression is constant; "if (sizeof(ElemType)==sizeof(float))" triggers this
#pragma warning (disable: 4702) // unreachable code; triggered for unknown reasons

Просмотреть файл

@ -13,6 +13,7 @@
#include "File.h"
#include "Helpers.h"
#include "CommonMatrix.h"
#include "BestGpu.h" // for CPUONLY macro
#ifndef CPUONLY
#pragma comment (lib, "CNTKMathCUDA.lib") // built by CNTKMathCUDA

Просмотреть файл

@ -73,7 +73,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>cudart.lib;cuda.lib;cublas.lib;cusparse.lib;curand.lib;libacml_mp_dll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libacml_mp_dll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<DelayLoadDLLs>cublas64_65.dll;cusparse64_65.dll;curand64_65.dll;cudart64_65.dll;nvcuda.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@ -122,7 +122,7 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<AdditionalDependencies>cusparse.lib;cublas.lib;cuda.lib;cudart.lib;curand.lib;libacml_mp_dll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libacml_mp_dll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Profile>true</Profile>
<DelayLoadDLLs>cublas64_65.dll;cusparse64_65.dll;curand64_65.dll;cudart64_65.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>

Просмотреть файл

@ -12,8 +12,13 @@
#include "GPUSparseMatrix.h"
#pragma warning (disable: 4100) // unreferenced formal parameter, which is OK since all functions in here are dummies; disabling this allows to copy-paste prototypes here when we add new functions
#pragma warning (disable: 4702) // unreachable code, which we get from the NOT_IMPLEMENTED macro which is OK
namespace Microsoft { namespace MSR { namespace CNTK {
short DeviceFromConfig(const ConfigParameters& /*config*/) { return CPUDEVICE; } // tells runtime system to not try to use GPUs
// the reset below are dummy implementations
void PrepareDevice(short deviceId);
#pragma region Constructors and Destructor