Recently need to use matconvnet under Ubuntu16.04. Because TensorFlow 1.6 supports Cuda 9.0, the new machine is loaded directly 9.0 but there are some problems when compiling matconvnet.
1. Error using MEX NVCC fatal:unsupported GPU architecture ' compute_20 '
Solution: This is because Cuda 8 does not support COMPUTE_20, the lowest is compute_30. So you need to modify the following code in the VL_COMPILENN.M
Opts.defcudaarch = [...
'-gencode=arch=compute_20,code=\ ' sm_20,compute_20\ "' ...
'-gencode=arch=compute_30,code=\ ' sm_30,compute_30\ "'];
I'm using gtx1080ti, and here I change it to
Opts.defcudaarch = [...
'-gencode=arch=compute_30,code=\ ' sm_30,compute_30\ "' ...
'-gencode=arch=compute_50,code=\ ' sm_50,compute_50\ "'];
You also need to make changes to the corresponding places in the Matconvnet/matlab/src/config/mex_cuda_glnxa64.xml.
nvccflags="-d_force_inlines-gencode=arch=compute_20,code=sm_20-gencode=arch=compute_30,code= 92;"sm_30,compute_30& #92;" $NVCC _flags"
After modification:
nvccflags="-d_force_inlines-gencode=arch=compute_30,code=sm_30-gencode=arch=compute_50,code= 92;"sm_30,compute_30& #92;" $NVCC _flags"
2. ERROR:MATLAB/SRC/BITS/IMPL/POOLING_GPU.CU (163): Error:function "Atomicadd (double, double)" has already been defined
The reason for this is that CUDA6.0 defines the atomicadd so that a duplicate definition of the error occurs. In a total of two files there is a problem with this duplicate definition, respectively, in
POOLING_GPU.CU, line 163
(commented out Atomicadd)
BILINEARSAMPLER_GPU.CU, line 25
(commented out Atomicadd)
Solution: The solution is to define the following macros in these two files
#if!defined (__cuda_arch__) | | __CUDA_ARCH__ >= 600
#else
< Place your own pre-pascal Atomicadd definition ...>
#endif
Copy the definition as above to the head in the file above, place the Atomicadd function cut defined in the file in the <, ... places here your own pre-pascal atomicadd definition ...>.
Reference:compiling with Cuda8 https://github.com/vlfeat/matconvnet/issues/575
"Record" compilation Matconvnet on ubuntu16.04 with Cuda 9.0