This post documents the process I followed to be able to run torch on my development machine after upgrading to Ubuntu 18.04 LTS. I had high hopes that the .deb
file provided by NVIDIA would “just work,” and it installed fine—but Torch and TensorFlow don’t yet support CUDA 10, so I had to sudo apt remove --purge --auto-remove cuda
and start over.
Installing CUDA
CUDA 9.1 is available from NVIDIA as an archived release, and I downloaded the runfile for Ubuntu 17.04.
This installed without complaint using the following command-line flags:
sudo ./cuda_9.1.85_387.26_linux.run --verbose --silent --toolkit --override
Next I ran the installer runfile again with --silent --samples
to install the sample content, then attempted to make
one of the example projects. The make failed because Ubuntu 18.04 ships with gcc 7.3 and CUDA 9.1 requires gcc 6. Following this forum post about the gcc version issue, I installed gcc-6
and g++-6
then symlinked CUDA’s bin references to uses these older versions:
sudo apt install gcc-6 g++-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
After a restart, the sample project built properly. Great! Time to install Torch.
Installing Torch
Using the Torch installation guide I pulled Torch down from Git, but immediately the install-deps
script gave me trouble.
Package python-software-properties is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
software-properties-common
E: Package 'python-software-properties' has no installation candidate
In Ubuntu 18.04 python-software-properties
is replaced by software-properties-common
, which in fact is also installed by the install-deps
script. To sidestep this error I commented out the line installing the defunct package, which should look like this once edited:
#sudo apt-get install -y python-software-properties
After this change, bash install-deps
now executed successfully.
Next, I needed to run ./install.sh
within the Torch directory. This script detects CUDA and attempts to install CUDA-specific lua extensions, but those installations fail because of the same GCC version issue discussed above.
You can specify a particular CC version using environment variables when running the luarocks install command directly, e.g. CC=gcc-6 CXX=g++-6 luarocks install cutorch
. Unfortunately this trick does not work at the level of the install.sh
script. To work around this, edit install.sh
and comment out anything inside of conditionals which check if [ -x "$path_to_nvcc" ]
: during initial installation we won’t even try to install anything CUDA-related. Once modified in this way, install.sh
should run to completion without complaint.
After installing all non-CUDA-related modules, we need to go back and add the cutorch
and cudnn
modules we commented out previously. We’ll be using the locally-installed copy of luarocks within the torch directory, and will set environment variables to ensure the proper version of GCC gets used. Run these commands from within the root torch directory:
CC=gcc-6 CXX=g++-6 install/bin/luarocks install cutorch
CC=gcc-6 CXX=g++-6 install/bin/luarocks install cunn
CC=gcc-6 CXX=g++-6 install/bin/luarocks install cudnn
Once cutorch
, cunn
, and cudnn
are installed, your CUDA 9.1 & Torch environment should be good to go. You will now be able to run neural-style, torch-rnn, or any other relevant torch modules.
A note on
torch-rnn
: Additional steps were needed to install the HDF5 package on Ubuntu 18.04, detailed in this pull request jcjohnson/torch-rnn#215 (Thank you, sharpie7)A further note on
neural-style
: After installing cudnn v7.1.3 for CUDA 9.1, I had to download and run an alternative version ofcudnn.torch
to avoid a version conflict where the bundled packages expected cudnn v5. See soumith/cudnn.torch#383, and note the commandsThis approach may require setting the environment variable
CUDNN_PATH
:Thank you. This solved some problems for me.
Thanks a lot, it works!
I’m stuck at CC=gcc-6 CXX=g++-6 install/bin/luarocks install cutorch,
luarocks is looking for a .zip in the URL but it is not found
https://raw.githubusercontent.com/torch/rocks/master/manifest-5.3.zip
Only https://raw.githubusercontent.com/torch/rocks/master/manifest-5.3 works
How to do ? So much difficulty for installing a soft on a ubuntu LTS….
I’m afraid I don’t know, my best suggestion would be to try to manually edit the script to download the right file. (Sorry for the delayed response)
I got other problem when running bash install-deps,
can you help me with resolve this?
Sorry, but I don’t understand enough about this to be able to help with this error.
The install-deps part doesnt work for me even after commenting it. I still got another error which is
Makefile:145: recipe for target ‘libs’ failed
make: *** [libs] Error 1
Error. OpenBLAS could not be compiled
I would appreciate if you can help
how to solve that error plz
nvcc fatal : Unsupported gpu architecture ‘compute_20’
I’m not familiar with that error, my best suggestion would be to check out this askubuntu thread where it looks like the same issue is discussed.
This is another issue that’s fairly easy to fix. Each generation of GPU has a code, I’m pretty sure you can look it up on NVIDIAs site. Change all the 20s to the number corresponding with you GPU and you’re good.
Thanks a lot K. Adam White, Its great help to the torch user, I have installed it in Ubuntu 20.04