适配CUDA10.1、Python3.7的Fastai/Torch/Torchvision版本及安装咨询
Hey there! Let's break down your questions and get you sorted out with the right versions and installation steps:
1. Compatible Versions for CUDA 10.1 & Python 3.7
After checking verified compatibility matrices and community feedback, here's the stable, tested combination for your setup:
- Fastai:
1.0.61(the last major release of Fastai v1 that works seamlessly with the below PyTorch/torchvision versions) - PyTorch:
1.3.1(compiled specifically for CUDA 10.1) - Torchvision:
0.4.2(compiled specifically for CUDA 10.1)
This set ensures no version mismatches and full compatibility with your environment.
2. Step-by-Step Installation to Fix the CUDA Version Mismatch
The error you're seeing is a classic case of PyTorch and torchvision being built against different CUDA versions. Let's fix this by doing a clean install of the matched versions:
Activate your new environment
First, make sure you're working in the environment you created:- For Conda environments:
conda activate your_env_name - For virtualenv (Linux/macOS):
source your_env_name/bin/activate - For virtualenv (Windows):
your_env_name\Scripts\activate
- For Conda environments:
Uninstall conflicting packages
Remove any existing versions of PyTorch, torchvision, and Fastai to avoid leftover files causing issues:pip uninstall -y torch torchvision fastaiIf you used Conda to install any of these, run
conda remove -y torch torchvision fastaiinstead.Install matched PyTorch & Torchvision (CUDA 10.1)
Choose the command that fits your package manager:- For Conda: This command installs pre-compiled packages built explicitly for CUDA 10.1, ensuring perfect version alignment:
conda install pytorch==1.3.1 torchvision==0.4.2 cudatoolkit=10.1 -c pytorch - For pip: The standardized wheel names will pull the correct CUDA 10.1-compatible versions for Python 3.7:
pip install torch==1.3.1+cu101 torchvision==0.4.2+cu101
- For Conda: This command installs pre-compiled packages built explicitly for CUDA 10.1, ensuring perfect version alignment:
Install compatible Fastai
Now install the Fastai version that pairs perfectly with these PyTorch/torchvision releases:pip install fastai==1.0.61Verify your installation
Run this quick check to confirm everything is working correctly:import torch import torchvision import fastai print(f"PyTorch version: {torch.__version__}") print(f"CUDA version in PyTorch: {torch.version.cuda}") print(f"Torchvision version: {torchvision.__version__}") print(f"Fastai version: {fastai.__version__}")You should see CUDA version
10.1listed for PyTorch, and all version numbers matching what we installed. No more mismatch errors!
内容的提问来源于stack exchange,提问作者PremaK

