1. 安装 cuda

大多数新发布的大语言模型使用了较新的 PyTorch v2.0+ 版本,Pytorch 官方认为 CUDA 最低版本是 11.8 以及匹配的 GPU 驱动版本。详情见Pytorch官方 如下图:
在这里插入图片描述

1.1 下载 cuda

cuda 12.1 官方网站
在这里插入图片描述
下载:

$wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run

1.2 安装 cuda

$sudo sh cuda_12.1.1_530.30.02_linux.run

然后,接受协议
在这里插入图片描述
由于已经安装显卡驱动,选择不安装,然后光标到 install 处,点击回车
在这里插入图片描述
同意覆盖原有的 /usr/local/cuda
查看cuda:

$ ll /usr/local/cuda
lrwxrwxrwx 1 root root 21 Mar  6 17:10 /usr/local/cuda -> /usr/local/cuda-12.1/

如果不是这样的话,重新链接

$sudo ln -s /usr/local/cuda-12.1 /usr/local/cuda

同时修改 ~/.bashrc

$ vim ~/.bashrc

在这里插入图片描述

$ source ~/.bashrc

然后查看 cuda 是否安装成功:

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Mon_Apr__3_17:16:06_PDT_2023
Cuda compilation tools, release 12.1, V12.1.105
Build cuda_12.1.r12.1/compiler.32688072_0

$ stat /usr/local/cuda
  File: /usr/local/cuda -> /usr/local/cuda-12.1/
  Size: 21        	Blocks: 0          IO Block: 4096   symbolic link
Device: 10303h/66307d	Inode: 20972187    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-03-06 17:14:48.054414724 +0800
Modify: 2024-03-06 17:10:45.351626652 +0800
Change: 2024-03-06 17:10:45.351626652 +0800
 Birth: -

2. 安装 cudnn

2.1 下载 cudnn

cudnn 官网,登录后可以直接点击下载
在这里插入图片描述

2.2 安装 cudnn

$ cd ~/Downloads/ & ls
$ tar -xvf cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
$ cd cudnn-linux-x86_64-8.9.7.29_cuda12-archive

$ sudo cp include/cudnn.h /usr/local/cuda-12.1/include/
$ sudo cp lib/libcudnn* /usr/local/cuda-12.1/lib64/
$ sudo chmod a+r /usr/local/cuda-12.1/include/cudnn.h /usr/local/cuda-12.1/lib64/libcudnn*

3. 安装 TensorFlow

参考 TensorFlow 官网

$ pip install tensorflow -i https://mirror.baidu.com/pypi/simple

4. 安装 Pytorch

参考 Pytorch 官网

在这里插入图片描述

$ pip3 install torch torchvision torchaudio

5. 安装 transformers

$ conda install -c conda-forge transformers

检验 transformers

$ python
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:53:32) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import transformers
>>> print(transformers.__version__)
4.38.2

参考:

  1. Ubuntu多CUDA版本安装及切换
  2. 【网络工具】ProxyChains配置教程 — 使国内Linux服务器能访问下载GitHub资源
GitHub 加速计划 / tra / transformers
130.24 K
25.88 K
下载
huggingface/transformers: 是一个基于 Python 的自然语言处理库,它使用了 PostgreSQL 数据库存储数据。适合用于自然语言处理任务的开发和实现,特别是对于需要使用 Python 和 PostgreSQL 数据库的场景。特点是自然语言处理库、Python、PostgreSQL 数据库。
最近提交(Master分支:2 个月前 )
33868a05 * [i18n-HI] Translated accelerate page to Hindi * Update docs/source/hi/accelerate.md Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * Update docs/source/hi/accelerate.md Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * Update docs/source/hi/accelerate.md Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * Update docs/source/hi/accelerate.md Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> --------- Co-authored-by: Kay <kay@Kays-MacBook-Pro.local> Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> 2 小时前
e2ac16b2 * rework converter * Update modular_model_converter.py * Update modular_model_converter.py * Update modular_model_converter.py * Update modular_model_converter.py * cleaning * cleaning * finalize imports * imports * Update modular_model_converter.py * Better renaming to avoid visiting same file multiple times * start converting files * style * address most comments * style * remove unused stuff in get_needed_imports * style * move class dependency functions outside class * Move main functions outside class * style * Update modular_model_converter.py * rename func * add augmented dependencies * Update modular_model_converter.py * Add types_to_file_type + tweak annotation handling * Allow assignment dependency mapping + fix regex * style + update modular examples * fix modular_roberta example (wrong redefinition of __init__) * slightly correct order in which dependencies will appear * style * review comments * Performance + better handling of dependencies when they are imported * style * Add advanced new classes capabilities * style * add forgotten check * Update modeling_llava_next_video.py * Add prority list ordering in check_conversion as well * Update check_modular_conversion.py * Update configuration_gemma.py 9 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐