以前装过arm架构下的深度学习环境还是有点麻烦的,在此记录一下
参考:http://blog.csdn.net/condom10010/article/details/128139401?ops_request_misc=&request_id=&biz_id=102&utm_term=orin%E5%B9%B3%E5%8F%B0%E6%9E%B6%E6%9E%84%E9%85%8D%E7%BD%AEtorch%E7%8E%AF%E5%A2%83&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-3-128139401.142v100control&spm=1018.2226.3001.4187

http://blog.csdn.net/qq_58728069/article/details/136292802?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171759001916800227447557%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=171759001916800227447557&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-6-136292802-null-null.142v100control&utm_term=orin%E5%B9%B3%E5%8F%B0%E6%9E%B6%E6%9E%84%E9%85%8D%E7%BD%AEtorch%E7%8E%AF%E5%A2%83&spm=1018.2226.3001.4187
arm架构下torch环境的安装

1. 查看arm域控 cuda 版本

nvcc -V
出现cuda版本cuda已完成安装

2. 下载archconda

    a) 命令sh Archiconda3-0.2.3-Linux-aarch64.sh
    b) 可能bash会报错 sudo gedit ~/.condarc 查看 将export行显示conda安装路径留着把报错的行删掉
    c) 可能需要换源
    d) 创建虚拟环境 conda create -n 环境名 python=3.8
    e) 激活 conda activate 环境名
    f) 禁用初始bash环境自启conda config --set auto_activate_base false

3. 选用适合的pytorch版本

    a) 网址[http://forums.developer.nvidia.com/t/pytorch-for-jetson/72048](http://forums.developer.nvidia.com/t/pytorch-for-jetson/72048)
    b) 推荐选择python3.8对应的torch版本
    c) 在虚拟环境下 运行pip install torch----------

4. 选择合适的torchvision版本

    **a) 由于pip install torchvision==版本号 不支持arm架构 所以需要编译torchvision源码**
    b) 查看torch和torchvision对应关系 网址[http://pytorch.org/get-started/previous-versions/](http://pytorch.org/get-started/previous-versions/)
    c) 然后去对应github上下载对应版本[http://github.com/pytorch/vision/tree/v0.13.0](http://github.com/pytorch/vision/tree/v0.13.0)
    d) 下载完成解压后进入目录 安装依赖包
        i. sudo apt-get install libopenblas-base libopenmpi-dev
        ii. pip install Cython  注意要在虚拟环境下安装
        iii. export BUILD_VERSION=0.13.0    
        iv. python setup.py install –user  注意编译过程很漫长 会报warning 但是不用介意
        v. 编译完成即可

环境检查的程序:
使用对应的python环境,然后:

import torch
 
class check_all:
    """
    检测当前设备torch、tensorflow安装状态
    """
    def __init__(self):
        """
        常量
        """
        torchvision = __import__("torchvision")
        tf          = __import__("tensorflow")
        self.tensorflow_version = tf.__version__
        self.tensorflow_is_gpu  = tf.test.is_built_with_cuda
        self.torch_version = torch.__version__
        self.cuda_version = torch.version.cuda
        self.torchvision_version = torchvision.__version__
        self.use_device = torch.cuda.current_device()
        p = torch.cuda.get_device_properties(self.use_device)
        self.gpu_size = int(p.total_memory/ 1024 ** 3)
        self.device_number = torch.cuda.device_count()
        self.gpu_name = torch.cuda.get_device_name(self.use_device)
        self.gpu_capability = torch.cuda.get_device_capability(self.use_device)
 
    def check(self):
        """
        检测输出
        """
        print("tensorflow版本{}".format(self.tensorflow_version))
        print("tensorflow是否为CUDA显卡驱动:{}".format("是"if self.tensorflow_is_gpu else "不是"))
        print("CUDA版本:{}".format(self.cuda_version))
        print("pytorch版本:{}
torchvision版本:{}".format(self.torch_version,self.torchvision_version))
        print("pytorch是否为CUDA显卡驱动:{}".format("是" if torch.cuda.is_available() else "不是"))
        print("当前设备显卡数量为:{},使用设备编号为:{}".format(self.device_number,self.use_device))
        print("当前使用的设备显卡名称为:{}".format(self.gpu_name))
        print("当前显卡算力为:{}
当前显卡的内存大小为:{}GB".format(self.gpu_capability,self.gpu_size))
 
 
 
if __name__ == '__main__':
    check = check_all()
    check.check()

这里也在检查tensorflow,也可以使用源码安装,直接就能安装(在对应的python环境下)

pip install tensorflow-2.8.0+nv22.4-cp38-cp38-linux_aarch64.whl
本站无任何商业行为
个人在线分享 » arm架构下torch环境的安装(主要是conda,torch,torchvision以及tensorflow)
E-->