> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autodl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 依赖安装

AutoDL中所有数据在关机后依然保留，包括安装的依赖文件，重启无需再次安装，[保留规则](https://docs.autodl.com/instance/data-storage/instance_data.md)。
如果你希望在租用其他主机时也复用依赖环境，那么可以尝试将系统盘中的所有数据保存为镜像或者迁移实例，请参考[保存镜像/加载镜像](https://docs.autodl.com/environment/image.md)、[迁移实例](https://docs.autodl.com/instance/migrate/migrate_instance.md)。

> [!TIP]
>
> 推荐使用国内源加速下载依赖包，但是网络高峰时如果某个源较慢，那么可以切换其他源提高下载速度，参考[软件源](https://docs.autodl.com/best_practices/tools/source.md)。

## 安装其他版本Python

所有的镜像中均带有Miniconda。

```
# 比如构建一个虚拟环境名为：my-env，Python版本为3.7
conda create -n my-env python=3.7    

# 更新bashrc中的环境变量
conda init bash && source /root/.bashrc

# 切换到创建的虚拟环境：my-env
conda activate my-env
```

## 安装其他框架

```
# PyTorch：从https://pytorch.org/get-started/previous-versions/找到合适的版本。比如：
pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1

# TensorFlow: 从https://www.tensorflow.org/install/pip找到对应版本链接。比如：
pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.6.0-cp38-cp38-manylinux2010_x86_64.whl
```

## Python依赖安装

```
# 使用pip，举例
pip install opencv-python scipy numpy Pillow

# 使用conda，举例
conda install numpy

# 如果不确定包名，通过搜索来查找
pip search xxxx
conda search xxxx

如果在用pip时不知道某个依赖有什么版本号，那么以下trick可以查看：随便写一个版本号，pip会报错出所有可安装的版本号
$ pip install xxx=9.9
```

## 系统依赖安装

```
# 以安装zip为例
apt-get update    # 只需要执行一次，不用每次都执行
apt-get install -y zip

# 如果不知道包名
apt-get update    # 只需要执行一次，不用每次都执行
apt-cache search xxxxx
```

CUDA等软件的安装请参考：[文档](https://docs.autodl.com/environment/cuda.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.