Created
August 30, 2022 01:17
-
-
Save Beomi/1943f7eee2ec77fddde6e61cf9bd7ed6 to your computer and use it in GitHub Desktop.
Install PyTorch with currently available system CUDA version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get cuda version and install torch | |
if nvcc --version 2&> /dev/null; then | |
# Determine CUDA version using default nvcc binary | |
CUDA_VERSION=$(nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p'); | |
elif /usr/local/cuda/bin/nvcc --version 2&> /dev/null; then | |
# Determine CUDA version using /usr/local/cuda/bin/nvcc binary | |
CUDA_VERSION=$(/usr/local/cuda/bin/nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p'); | |
elif [ -f "/usr/local/cuda/version.txt" ]; then | |
# Determine CUDA version using /usr/local/cuda/version.txt file | |
CUDA_VERSION=$(cat /usr/local/cuda/version.txt | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/') | |
else | |
CUDA_VERSION="" | |
fi | |
pip3 install torch --extra-index-url "https://download.pytorch.org/whl/cu${CUDA_VERSION/./}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install with 1-line code