It is not trivial to compile pytorch on Fedora 26 as the gcc compiler 7.1.1 is not compatible with Cuda 8.0. This note describes a way around this problem.

  • Compile from source an old gcc version that is compatible with cuda. I used the latest version in the 5 series, 5.4.0 . The compiler source may be downloaded from: https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/ . Note that this is quite a time consuming compilation.
  • Compile pytorch with the following command line:
env CC=/usr/local/gcc-5.4.0/bin/gcc  \
    CXX=/usr/local/gcc-5.4.0/bin/g++ \
    CUDA_NVCC_FLAGS="-ccbin=/usr/local/gcc-5.4.0/bin/g++" \
    python2 setup.py install --prefix=/usr/local
  • Make sure that your PYTHONPATH includes the following two directories:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:\
                  /usr/local/lib64/python2.7/site-packages:
  • Test that everything works:
ipython2
... import torch
... torch.version.__version__
  • To install pytorch-vision apply the following path, whereupon pytorch-vision may be installed with a simple python setup.py install.
diff --git a/setup.py b/setup.py
index a83d889..d2a16bc 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,6 @@ requirements = [
     'numpy',
     'pillow',
     'six',
-    'torch',
 ]