Here's the code, I am trying to compile using make command in command prompt.
nvcc := "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc"
cudalib := "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/extras/CUPTI/lib64"
cudainclude := "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/include"
tensorflow := C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64
TF_CFLAGS := $$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')
TF_LFLAGS := $$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')
all: tf_nndistance_so.so
clean:
rm -rf *.o *.so
.PHONY : all clean
tf_nndistance_so.so: tf_nndistance_g.o tf_nndistance.cpp
g -std=c 11 -shared tf_nndistance.cpp tf_nndistance_g.o -o tf_nndistance_so.so -fPIC $(TF_CFLAGS) $(TF_LFLAGS) -O2
tf_nndistance_g.o: tf_nndistance_g.cu
$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c 11 -c -o tf_nndistance_g.o tf_nndistance_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2
But getting the following error:
"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc" -D_GLIBCXX_USE_CXX11_ABI=0 -std=c 11 -c -o tf_nndistance_g.o tf_nndistance_g.cu -I C:/"Program Files (x86)"/"Microsoft Visual Studio"/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
make: *** [Makefile:19: tf_nndistance_g.o] Error 1
Any suggestions are welcome.
Thank you.
CodePudding user response:
Install Visual Studio.
You will need to add the folder containing the "cl.exe" file to your path environment variable. For example:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
go to My Computer -> Properties -> Advanced System Settings -> Environment Variables
. Here look for "PATH
" in the list, and add the path above (or whatever is the location of your cl.exe).
CodePudding user response:
The immediate problem
You need to set your VStudio (2019 that you already have installed) paths.
A common way of doing that is invoking vcvarsall.bat: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
.
More details on building from command line: [SO]: How to build a DLL version of libjpeg 9b? (@CristiFati's answer).
The bigger problem
You are mixing compilers:
- CUDA Toolkit uses (by default) VStudio (native) compiler (cl.exe)
- You are using g .exe
This is a bad idea you should stick to one compiler (cl - as instructed in previous section). Note that some flags that you use are not compatible.
Or instruct CUDA to use g (don't know what build toolchain it belongs to, and don't know if possible).