以前在FreeBSD下也安装过Pytorch,当时pkg安装有问题,所以最终是使用的conda安装,非常复杂繁琐。现在pkg安装已经非常简单方便了。
以前FreeBSD下用conda安装pytorch:python安装pytorch@FreeBSD_failed to build pytorch-CSDN博客
FreeBSD下安装Transformers:python安装transformers包@FreeBSD_pyhton如何安装transformers版本-CSDN博客
FreeBSD系统下 安装
先看看系统版本:
uname -a
FreeBSD fb5 14.1-BETA3
安装python3.11
pkg install python3.11
安装pytorch
pkg install py311-pytorch
安装tokenizers
pkg install py311-tokenizers
因为以上都是用pkg安装的,所以速度都比较快!
使用pip安装Transformers
pip3.11 install transformers
这样就齐活了!
测试pytorch
>>> import torch
>>> x = torch.randn((2,3))
>>> y = x+1
>>> y
tensor([[ 0.1640, 0.0577, -0.1759],
[ 1.3309, 2.4186, 0.2721]])
测试Transformers
先设置huggingface镜像
export HF_ENDPOINT=https://hf-mirror.com
测试,使用一个语音转文字的模型:
>>> from transformers import pipeline
>>> from transformers.pipelines.audio_utils import ffmpeg_microphone_live
>>>
>>> asr_model_id = "openai/whisper-tiny.en"
>>> transcriber = pipeline("automatic-speech-recognition",
... model=asr_model_id,
... device="cpu",
... )
model.safetensors: 100%|██████████████████████████████████████████████████| 151M/151M [00:43<00:00, 3.48MB/s]
generation_config.json: 1.62kB [00:00, 2.97MB/s]
tokenizer_config.json: 805B [00:00, 1.90MB/s]
vocab.json: 798kB [00:00, 1.44MB/s]
tokenizer.json: 2.41MB [00:00, 4.90MB/s]
merges.txt: 456kB [00:00, 977kB/s]
normalizer.json: 52.7kB [00:00, 33.9MB/s]
added_tokens.json: 34.6kB [00:00, 30.8MB/s]
special_tokens_map.json: 1.83kB [00:00, 4.60MB/s]
preprocessor_config.json: 185kB [00:00, 104MB/s]
Device set to use cpu
测试完成!
标签:Transformers,install,Pytorch,pytorch,pkg,FreeBSD,transformers,安装 From: https://blog.csdn.net/skywalk8163/article/details/144323986