N8-CIR-Bede / documentation

Documentation for the N8CIR Bede Tier 2 HPC faciltiy
https://bede-documentation.readthedocs.io/en/latest/
7 stars 10 forks source link

Torchaudio installation note / instructions #165

Open ptheywood opened 1 year ago

ptheywood commented 1 year ago

Open-CE does not provide binary installs of torchaudio (but does include pytorch and torchvision).

Adding a mention of this to the pytorch page may be worthwhile, along with instructions to build from source (which is not completely trivial)

# Create a conda environment, with Open-CE 1.8.0 set up (important to know the version of pytorch/torchaudio to build
conda create -y --name torchaudio python=3.10
conda activate torchaudio

conda config --env --prepend channels https://ftp.osuosl.org/pub/open-ce/1.8.0/
conda config --env --set channel_priority strict

# Install pytorch 1.13.0 and the matching cuda toolkit from open-ce, including nvcc. Linking failed using the system provided nvcc. 
conda install -y pytorch==1.13.0 cudatoolkit cudatoolkit-dev cmake 

# Conda should be setting environment variables so nvcc, include dirs ans so files can be found, but if not set these vars manually. 
export PATH=${CONDA_PREFIX}/bin:${PATH}
export CPATH=${CONDA_PREFIX}/include:${CPATH}
export LIBRARY_PATH=${CONDA_PREFIX}/lib:${LIBRARY_PATH}
export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib64:${LD_LIBRARY_PATH}

# Clone torch audio v0.13.0 release - i.e. matching the torch version 
git clone --depth 1 --branch v0.13.0 https://github.com/pytorch/audio.git

# Change into the audio directory, 
cd audio

# Build pytorch audio from source. This may take a while.
python3 setup.py install

# Change out of the audio directory
cd ../

# Confirm it is installed 
python3 -c "import torchaudio; print(torchaudio.__version__)"

It is unclear to me why I had to export the variables above on Bede, as conda should have handled those for me afiak.

willfurnass commented 1 year ago

Buliding a conda package could be another option (untested on ppc64le): https://github.com/pytorch/audio/blob/main/packaging/build_conda.sh

ptheywood commented 1 year ago

Buliding a conda package could be another option (untested on ppc64le): https://github.com/pytorch/audio/blob/main/packaging/build_conda.sh

I considered attempting to produce a conda package, but the various bash scripts that calls out to would need ammending to reference the Open-CE conda channel instead (for ppc64le builds of pytorch which are not provided by the pytorch channels explicitly referenced in https://github.com/pytorch/audio/blob/main/packaging/pkg_helpers.bash), although presumably for a one-off build the appropriate conda build command could probably be found.

A more open-ce like / compatible approach would be to create a torchaudio version of https://github.com/open-ce/torchvision-feedstock

willfurnass commented 1 year ago

Figured out what system(s) the ppc64le open-ce conda feedstock packages are build on?

ptheywood commented 1 year ago

They will be run by the conda channel hosts, which are currently OSU and MIT.

open-ce/open-ce-builder describes how to build packages from feedstocks (either collections or individual packages) but that is as far as I looked into this.