ghailey / 3Dshapes

generate 3D shapes
0 stars 0 forks source link

安装torch时Fails to build against CUDA 10 #1

Open ghailey opened 5 years ago

ghailey commented 5 years ago

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_cublas_device_LIBRARY (ADVANCED) linked by target "THC" in directory /home/ghy/torch/extra/cutorch/lib/THC

-- Configuring incomplete, errors occurred! See also "/home/ghy/torch/extra/cutorch/build/CMakeFiles/CMakeOutput.log". See also "/home/ghy/torch/extra/cutorch/build/CMakeFiles/CMakeError.log".

ghailey commented 5 years ago

How to build Torch with CUDA10 Install the latest CMake from github repo (the latest FindCUDA.cmake will be installed) $ sudo apt-get purge cmake $ git clone https://github.com/Kitware/CMake.git $ cd CMake $ ./bootstrap; make; sudo make install Remove FindCUDA.cmake. $ cd ~/torch $ rm -fr cmake/3.6/Modules/FindCUDA Apply the following patch to cutorch diff --git a/lib/THC/THCAtomics.cuh b/lib/THC/THCAtomics.cuh index 400875c..ccb7a1c 100644 --- a/lib/THC/THCAtomics.cuh +++ b/lib/THC/THCAtomics.cuh @@ -94,6 +94,7 @@ static inline device void atomicAdd(long address, long val) { }

ifdef CUDA_HALF_TENSOR

+#if !(CUDA_ARCH >= 700 || !defined(CUDA_ARCH) ) static inline device void atomicAdd(half address, half val) { unsigned int address_as_ui = (unsigned int ) ((char )address - ((size_t)address & 2)); @@ -117,6 +118,7 @@ static inline device void atomicAdd(half *address, half val) { } while (assumed != old); }

endif

+#endif $ cd extra/cutorch $ cat > atomic.patch

$ patch -p1 < atomic.patch Build $ ./clean.sh $ export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__" $ ./install.sh