arm架构Linux系统下安装CUDA及pytorch

cuda在线安装命令,直接复制粘贴

# 安装 CUDA 工具包 11.4 版本。'-y' 参数是同意所有提示,无需手动确认。

        sudo apt install cuda-toolkit-11-4 -y

# 安装针对 CUDA 的 NVIDIA 深度神经网络库开发包(cuDNN)。'-y' 参数同意安装过程中的所有提示

        sudo apt install libcudnn8-dev -y

# 安装 NVIDIA TensorRT,这是一个用于深度学习推理的优化库。'-y' 参数用于自动确认安装。(这个根据需求安装,不需要就不用安装)

        sudo apt install tensorrt -y

添加环境变量(下面三行必须添加)

# 为 CUDA 设置环境变量,指定 CUDA 的安装目录。

        export CUDA_HOME=/usr/local/cuda-11.4

# 将 CUDA 库的路径添加到系统的库文件搜索路径中,这样程序可以找到 CUDA 库。

        export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64:$LD_LIBRARY_PATH

# 将 CUDA 的可执行文件路径添加到系统的 PATH 环境变量中,使得用户可以在任何位置调用 CUDA 程序和工具。

        export PATH=/usr/local/cuda-11.4/bin:$PATH

然后安装pytorch

我这边选的离线安装,这是下载网址(进入选合适的版本)

PyTorch for Jetson - Jetson & Embedded Systems / Announcements - NVIDIA Developer Forums

然后scp直接拉到一个路径下直接命令,比较快()

pip install --no-index --find-links=你的路径 torch-1.12.0a0+2c916ef.nv22.3-cp38-cp38-linux_aarch64.whl

然后可能会报错,没报错就不用看下边了,如果是这个报错,一般都是无法找到 libopenblas.so.0 这个共享对象文件,直接命令下载

sudo apt-get update

sudo apt-get install libopenblas-base

完事就可以了,如果还不行直接把路径添加到环境变量里边,下边命令,把路径改了就行

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

### PyTorch on ARM Architecture Installation and Usage For installing PyTorch on an ARM architecture, the process involves ensuring compatibility with the hardware specifics of ARM-based systems. Given that many pre-built binaries are optimized for x86 architectures, special attention must be paid to finding or building compatible versions. #### Installing Dependencies via APT Before proceeding with PyTorch installation, it is essential to ensure all necessary dependencies are installed using `apt`. Since the system might be a minimal version like mentioned previously[^2], updating package lists and installing Python along with pip should come first: ```bash sudo apt update && sudo apt upgrade -y sudo apt install python3 python3-pip -y ``` #### Setting Up Environment Using Conda Given the flexibility provided by environments managed through tools such as conda, initializing one specifically tailored towards machine learning tasks can streamline dependency management significantly. Starting from creating a new environment based on Miniconda initialization script execution noted earlier[^3]: ```bash bash Miniconda3-latest-Linux-aarch64.sh conda create --name pytorch_env python=3.9 conda activate pytorch_env ``` #### Installing PyTorch Compatible with ARM Directly pulling precompiled packages may not always work due to potential mismatches between target platforms (e.g., x86 vs. ARM). Therefore, opting for wheels built explicitly for ARM processors becomes crucial. One approach could involve downloading these directly from sources supporting ARM builds or leveraging community-maintained repositories: ```bash pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu ``` However, when targeting GPU acceleration on ARM devices equipped with NVIDIA GPUs, following the specified order regarding driver installations remains important[^4]. This means starting with appropriate graphics drivers followed by CUDA toolkit suitable for ARM before moving onto cuDNN and finally PyTorch itself. #### Verifying Installation Success After completing setup steps above, verifying whether everything works correctly helps identify any issues early: ```python import torch print(torch.__version__) if torch.cuda.is_available(): print('CUDA available') else: print('Running on CPU') ``` --related questions-- 1. What specific challenges arise while setting up deep learning frameworks on non-x86 architectures? 2. How does choosing different Python versions impact library compatibility during development? 3. Can you explain how to set up a virtual environment without internet access using only local files? 4. In what scenarios would someone prefer compiling libraries from source over using binary distributions?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值