安装unsloth

我在llamafactory微调LLM,简单测了一些(很不精准),加速方法中unsloth比flash_attention速度快了40%,显存占用减少15%;

  1. 创建虚拟环境:conda create -n env_name python=3.10, 然后conda activate env_name
  2. 安装cudatoolkit:conda install cudatoolkit=12.1conda install nvidia/label/cuda-12.1.0::cuda-toolkit,可能失败
  3. 安装pytorch、triton和xformers:pip install torch==2.4.0 triton pip install xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121(如果第二步失败,这步也会配上cuda环境)(嫌慢可以先去https://download.pytorch.org/whl/cu121把包下好,不过记得这几个包一起安装,不然可能会覆盖前面安装的,例如单独安装triton和xformers会下载cpu版torch)
  4. 安装unsloth:pip install "unsloth[cu121-torch240] @ git+https://github.com/unslothai/unsloth.git"或者pip install --upgrade --force-reinstall --no-cache-dir git+https://github.com/unslothai/unsloth.git,我试的时候直接pip install unsloth torch=2.4.0+cu121也能安装成功(命令里带上torch是为了让它别装其它版本)
  5. 记得比对一下包的版本是不是如上所述,因为有的包可能会把依赖包卸了装个新的。。(包不太容易安装,依赖很复杂,所以不建议用--no-deps--ignore-installed等方式)

第5步有大佬在博客说要装ampere,我是没装也能用(尝试装了下,在flash-attn那里卡住了),仅供参考:pip install "unsloth[cu121-ampere-torch240] @ git+https://github.com/unslothai/unsloth.git"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值