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.
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
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.
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:
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
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