harskish / ganspace

Discovering Interpretable GAN Controls [NeurIPS 2020]
Apache License 2.0
1.78k stars 264 forks source link

Issues installing on Ubuntu 20.04 (Solved) #49

Closed pikawika closed 3 years ago

pikawika commented 3 years ago

Setup (with extra's for Ubuntu 20.04)

  1. Install anaconda or miniconda
  2. Install git, then clone respository: git clone https://github.com/harskish/ganspace/
  3. Create environment: conda create -n ganspace python=3.7
  4. Activate environment: conda activate ganspace
    • EXTRA: cd ganspace/
  5. Install dependencies: conda env update -f environment.yml --prune
  6. Setup submodules: git submodule update --init --recursive
  7. Run command python -c "import nltk; nltk.download('wordnet')"

Interactive viewer

The interactive viewer (interactive.py) has the following dependencies:

Linux (ubuntu 20.04)

EXTRA: Activate environment: conda activate ganspace

  1. Install CUDA toolkit (match the version in environment.yml)
    • EXTRA: Follow instructions from here
    • EXTRA: sudo apt install ctags
    • EXTRA: export CUDA_HOME=/usr/local/cuda-10.1
  2. Download pycuda sources from: https://pypi.org/project/pycuda/#files
  3. Extract files: tar -xzf pycuda-VERSION.tar.gz
    • EXTRA: cd pycuda-VERSION/
  4. Configure: python configure.py --cuda-enable-gl --cuda-root=/path/to/cuda
    • EXTRA: used this one instead python configure.py --cuda-root=$CUDA_HOME --cuda-enable-gl
  5. Compile and install: make install
    • EXTRA: sudo apt -y install gcc-8 g++-8
    • EXTRA: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
    • EXTRA: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8
    • EXTRA: pip install pytest
    • EXTRA: cd test/
    • EXTRA: python test_driver.py
      • EXTRA: should all be green (and thus 100%)
  6. Install Glumpy: pip install setuptools cython glumpy
    • EXTRA: before this pip install, install required package, namely: pip install Cython

EXTRA: non installed pip dependencies

StyleGAN2 setup (optional)

StyleGAN2 contains custom CUDA kernels for improved performance.
Less performant native PyTorch fallbacks are used by default.

EXTRA: go to root of ganspace

  1. Install CUDA toolkit (match the version in environment.yml)
    • EXTRA: already done in previous step
  2. conda activate ganspace
    • EXTRA: export CUDA_HOME=/usr/local/cuda-10.1
    • EXTRA: sudo cp /usr/local/cuda-10.2/targets/x86_64-linux/include/cublas_v2.h /usr/local/cuda-10.1/targets/x86_64-linux/include/cublas_v2.h
    • EXTRA: sudo cp /usr/local/cuda-10.2/targets/x86_64-linux/include/cublas_api.h /usr/local/cuda-10.1/targets/x86_64-linux/include/cublas_api.h
  3. cd models/stylegan2/stylegan2-pytorch/op
  4. python setup.py install
  5. Test: python -c "import torch; import upfirdn2d_op; import fused; print('OK')"
pikawika commented 3 years ago

I've posted a somewhat updated setup.md for people having the same issues as me, such as: