logo

Ubuntu上使用Conda安装PyTorch-GPU和Hugging Face

作者:热心市民鹿先生2024.01.17 23:21浏览量:7

简介:在Ubuntu上使用Conda环境安装PyTorch-GPU和Hugging Face,需要先创建Conda环境,然后配置Conda源,最后安装PyTorch-GPU和Hugging Face。下面是一个详细的步骤指南。

首先,确保你的系统已经安装了Anaconda或Miniconda。你可以从Anaconda官网下载并安装。
一旦Anaconda安装完成,你可以通过以下命令创建一个新的conda环境(这里我们将其命名为’pytorch-gpu’):
conda create -n pytorch-gpu python=3.6
然后激活新创建的环境:
conda activate pytorch-gpu
接下来,我们需要配置Conda的源,以便可以从清华大学提供的镜像站点下载PyTorch和其他依赖项。执行以下命令:
condaconfig —addchannels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
condaconfig —addchannels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
condaconfig —addchannels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
注意:在上述命令中,我们将源的地址从https更改为http,以避免出现CondaHTTPError。
然后,你可以选择两种方法之一来安装PyTorch-GPU和MKL。方法一(推荐):
conda install pytorch-gpu conda install mkl
或者方法二:

  1. 转到清华镜像站点下载对应版本的PyTorch包(例如,https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/)。
  2. 下载完成后,进入下载目录,执行以下命令进行安装:
    cd ~/Downloads/
    conda install —offline pytorch-1.0.1-py3.6_cuda8.0.61_cudnn7.1.2_0.tar.bz2 conda install mkl
    一旦PyTorch和MKL安装完成,你就可以安装Hugging Face了。执行以下命令:
    conda install -c conda-forge huggingface_hub
    conda install -c conda-forge transformers
    conda install -c conda-forge torch-scatter torch-sparse torch-cluster torch-spline-conv -c conda-forge
    conda install -c conda-forge torch-geometric -c conda-forge torch-scatter torch-sparse torch-cluster torch-spline-conv -c conda-forge
    conda install -c conda-forge torchxrayvision -c conda-forge torchvision torchvision-datasets torchvision-models -c conda-forge
    conda install -c conda-forge timm -c conda-forge efficientnet_pytorch efficientnet_pytorch_pretrained_models -c conda-forge
    conda install -c conda-forge sentencepiece -c conda-forge fairseq -c conda-forge pyttsx3 -c conda-forge sacremoses -c conda-forge tqdm -c conda-forge nltk nltk data -c conda-forge pyworld pyworld_datasets -c conda-forge openai_transformer openai_transformer_datasets -c conda-forge pyecharts -c conda-forge plotly -c conda-forge matplotlib scikit_learn pandas seaborn imbalanced_learn xgboost lightgbm fastparquet statsmodels scikit_image openpyxl graphviz pyarrow pyaml protobuf lxml -c conda-forge

相关文章推荐

发表评论