Install Torch in Ubuntu and configure CUDA and cuDNN

Source: Internet
Author: User

Install Torch in Ubuntu and configure CUDA and cuDNN
General description

Ubuntu is 14.04, and cuda is 7.5 cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64. Cudnn is 7.5, cudnn-7.5-linux-x64-v5.0-ga.tgz.
Reference: Link: https://github.com/jcjohnson/neural-style/blob/master/INSTALL.md
Neural-style
In fact, this article has clearly explained how to install it, but it still encountered many pitfalls during installation.

Pit1: A lot of torch dependent libraries !!
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash

When running this command, it will take a long time to install it !!!! Because my network here is very poor, if you have a similar situation, it may occur: "xxx checksum does not match ". In this case, the dependent database is not installed !! I thought it was already installed. I just finished neural-style and then./install. sh. I wiped it and the result showed cmake not found and so on. Then I went to sudo apt-get install cmake. The results show other mess, now is a sentence: curl-s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash is to install all the dependent libraries !! After installation, a similar message is displayed: "torch dependencies have already installed ."

Pit2: cuda installation, Version mismatch
wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/rpmdeb/cuda-repo-ubuntu1404-7-0-local_7.0-28_amd64.debsudo dpkg -i cuda-repo-ubuntu1204-7-0-local_7.0-28_amd64.deb

This theory seems to be correct, but later

sudo apt-get updatesudo apt-get install cuda

Here apt-get is used to get cuda7.5 !! It does not match the version installed above! So the correct method:
Download it from the official website and install it!
Based on my ubuntu version, I chose
Cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb

If the cuda version obtained by apt-get is later, you must install the corresponding version!

Pit 3 cudnn and cuda versions must match!

Original

tar -xzvf cudnn-7.0-linux-x64-v4.0-prod.tgzsudo cp cuda/lib64/libcudnn* /usr/local/cuda-7.0/lib64/sudo cp cuda/include/cudnn.h /usr/local/cuda-7.0/include/luarocks install cudnn

Here to download for cuda7.5, here is the cudnn-7.5-linux-x64-v5.0-ga.tgz
Of course

sudo cp cuda/include/cudnn.h /usr/local/cuda-7.0/include/

7.0 to 7.5.

Pit4 may cause 'libcudnn not found in library path '.

Intercept an error message:

Please install CuDNN from https://developer.nvidia.com/cuDNNThen 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)

LD_LIBRARY_PATH is the environment variable. It is mainly used to specify other paths except the default path for finding a shared library (dynamic link library. Because
"Libcudnn *" is copied to/usr/local/cuda-7.5/lib64/, so you need

  1. Sudo gedit/etc/ld. so. conf. d/cudnn. conf is to create a new conf file. Casual name
  2. Add the path/usr/local/cuda-7.5/lib64/
  3. Anyway, I also added/usr/local/cuda-7.5/include/, which is probably not enough.
  4. Save the settings and then update the cache using sudo ldconfig. (Libcudnn. so.5 is not a symbolic connection, but it doesn't matter !!)

Run

th neural_style.lua -gpu 0 -backend cudnn

Success !!!!

It is found that when cudnn is used, it becomes 50 and 50, and the speed is faster. Just now, cuda is only one display. Don't talk about it. Please wait.

Summary

Make sure the version matches !! Later, apt-get will get a later version of cuda and cudnn. At this time, you must download the corresponding version for installation according to the actual situation. The method is similar.

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.