1、按照Torch官网给出安装教程
执行./install.sh时遇到
error: more than one operator "==" matches these operands:
function "operator==(const __half &, const __half &)"
function "operator==(half, half)"
operand types are: half == half
解决方法:命令行输入
export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__"
2、安装DenseCap相关库stnbhwd
DenseCap提供安装命令如下:
luarocks install https://raw.githubusercontent.com/qassemoquab/stnbhwd/master/stnbhwd-scm-1.rockspec
出现编译错误:
[ 25%] Building C object CMakeFiles/stn.dir/init.c.o
[ 50%] Linking C shared module libstn.so
[ 50%] Built target stn
[ 75%] Building NVCC (Device) object CMakeFiles/custn.dir/custn_generated_init.cu.o
nvcc fatal : Value 'sm_20' is not defined for option 'gpu-architecture'
CMake Error at custn_generated_init.cu.o.cmake:207 (message):
Error generating
/tmp/luarocks_stnbhwd-scm-1-4197/stnbhwd/build/CMakeFiles/custn.dir//./custn_generated_init.cu.o
CMakeFiles/custn.dir/build.make:63: recipe for target 'CMakeFiles/custn.dir/custn_generated_init.cu.o' failed
make[2]: *** [CMakeFiles/custn.dir/custn_generated_init.cu.o] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/custn.dir/all' failed
make[1]: *** [CMakeFiles/custn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Error: Build error: Failed building.
解决方法:
1.下载源码到本地:git clone https://github.com/qassemoquab/stnbhwd
2.修改CMakeLists.txt:
From:
IF (CUDA_FOUND)
LIST(APPEND CUDA_NVCC_FLAGS "-arch=sm_20")
to:
IF (CUDA_FOUND)
LIST(APPEND CUDA_NVCC_FLAGS "-arch=sm_30")
3.在源码目录里执行本地安装:luarocks make
3、运行DenseCap
cudnn报错,以为是路径的问题:
/home/ubuntu/torch/install/bin/luajit: /home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: /home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: /home/ubuntu/torch/install/share/lua/5.1/cudnn/ffi.lua:1603: 'libcudnn (R5) not found in library path.
Please install CuDNN from https://developer.nvidia.com/cuDNN
Then make sure files named as libcudnn.so.5 or libcudnn.5.dylib are placed in
your library load path (for example /usr/local/lib , or manually add a path to LD_LIBRARY_PATH)
Alternatively, set the path to libcudnn.so.5 or libcudnn.5.dylib
to the environment variable CUDNN_PATH and rerun torch.
For example: export CUDNN_PATH="/usr/local/cuda/lib64/libcudnn.so.5"
stack traceback:
[C]: in function 'error'
/home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
neural_style.lua:350: in function 'setup_gpu'
neural_style.lua:53: in function 'main'
neural_style.lua:601: in main chunk
[C]: in function 'dofile'
...untu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50
命令行执行语句:
export CUDNN_PATH="/usr/local/cuda-9.0/lib64/libcudnn.so.7"
出现新提示:
Found Environment variable CUDNN_PATH = /usr/local/cuda-9.0/lib64/libcudnn.so.7/home/ubuntu/torch/install/bin/luajit: /home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: /home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: /home/ubuntu/torch/install/share/lua/5.1/cudnn/ffi.lua:1618: These bindings are for CUDNN 5.x (5005 <= cudnn.version > 6000) , while the loaded CuDNN is version: 7003
Are you using an older or newer version of CuDNN?
stack traceback:
[C]: in function 'error'
/home/ubuntu/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
neural_style.lua:350: in function 'setup_gpu'
neural_style.lua:53: in function 'main'
neural_style.lua:601: in main chunk
[C]: in function 'dofile'
...untu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50
正确解决方法(应该是直接利用luarocks安装cudnn时默认安装了5版本):
git clone https://github.com/soumith/cudnn.torch.git -b R7 && cd cudnn.torch && luarocks make cudnn-scm-1.rockspec
可能遇到执行luarocks提示没有操作权限的问题。
解决方法:
获取root权限,然后调用/home/usrname/torch/install/bin/luarocks
即可,例如:
/home/usrname/torch/install/bin/luarocks make
代码运行示例: