装了一天终于装好了。。。。试了包括CSDN自己的平台,看了好多帖子,没想到最后用很简单的方法就装好了

  • 显卡: NVIDIA 显卡,显存建议至少 8GB (示例中使用 RTX 4090 24GB))。
  • Python 版本: 推荐 Python 3.11 (截至编写时,较新版本可能存在兼容性问题)。
  • CUDA: 需要预先安装与你NVIDIA驱动兼容的CUDA Toolkit。本教程以CUDA 11.8 (cu118) 为例。
  • audl算力平台

1. 创建 Conda 虚拟环境

首先,创建一个独立的 Conda 环境以隔离项目依赖。请确保文件夹路径不包含中文字符,以避免潜在问题。

打开你的命令行终端 (如 PowerShell 或 CMD),执行成功的话,命令行最前面应该有一个(unslothAmr)

conda create -n unslothAmr python=3.11
conda init bash
conda activate unslothAmr

2. 安装 Unsloth 

pip install unsloth -i https://pypi.tuna.tsinghua.edu.cn/simple

3. 检查torch版本是CPU还是GPU

import torch

# 检查 CUDA 是否可用
print("CUDA available:", torch.cuda.is_available())

# 如果可用,打印 CUDA 设备数量和当前设备名称
if torch.cuda.is_available():
    print("Number of CUDA devices:", torch.cuda.device_count())
    print("Current CUDA device:", torch.cuda.current_device())
    print("CUDA device name:", torch.cuda.get_device_name(torch.cuda.current_device()))
else:
    print("CUDA is not available. Running on CPU.")

如果显示

CUDA available: True
Number of CUDA devices: 1
Current CUDA device: 0

继续下一步

pip install ipykernel
python -m ipykernel install --user --name=unsloth-kernel --display-name="Python (unslothAmr)"

输出结果

Installed kernelspec unsloth-kernel in /root/.local/share/jupyter/kernels/unsloth-kernel

后,新建一个notebook,选择内核 "Python (unslothAmr)",测试

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐