How to install nvidia apex on Google Colab

(wanted to just add a comment but I don't have enough reputation...)

it works for me but the cd is actually not required. Also, I needed the two global options as suggested here: https://github.com/NVIDIA/apex/issues/86

%%writefile setup.sh

git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex

then

!sh setup.sh

Updated

First, create a file e.g. setup.sh as follows:

For apex with CUDA and C++ extensions:

%%writefile setup.sh

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

Then, install it

!sh setup.sh

For Python-only build

%%writefile setup.sh

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir ./

A Python-only build omits certain Fused kernels required to use apex.optimizers.FusedAdam, apex.normalization.FusedLayerNorm, etc.

Check apex quickstart.


Worked for me after adding CUDA_HOME enviroment variable:

%%writefile setup.sh

export CUDA_HOME=/usr/local/cuda-10.1
git clone https://github.com/NVIDIA/apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex
!sh setup.sh