"Record" compilation Matconvnet on ubuntu16.04 with Cuda 9.0

Source: Internet
Author: User
Tags nvcc

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.