当前位置: 首页 > wzjs >正文

手机web页面设计网站百度最新版本2022

手机web页面设计网站,百度最新版本2022,培训行业网站建设的重要性,html在线编程网站win10 笔记本电脑安装 pytorchcudagpu 大模型开发环境过程记录 文章部分内容参考 deepseek。 以下使用命令行工具 mingw64。 安装 Anaconda 安装位置: /c/DEVPACK/Anaconda3 然后安装 Python 3.10.16 (略) $ conda create -n pytorch_…

win10 笔记本电脑安装 pytorch+cuda+gpu 大模型开发环境过程记录

文章部分内容参考 deepseek。

以下使用命令行工具 mingw64。

安装 Anaconda

安装位置:

/c/DEVPACK/Anaconda3

然后安装 Python 3.10.16
(略)

$ conda create -n pytorch_env python=3.10
$ conda activate pytorch_env

安装 CUDA cuDNN

安装 cuda toolkit 会更新系统的显卡驱动。尽管我的 Thinkpad X1 驱动已经是最新,但是仍然比 Nvidia 提供的旧。所以要更新 N 卡驱动。因为 pytorch 支持 12.6,所以我选择 cuda12.6。

下载:
cuda_12.6.3_561.17_windows.exe
cudnn_9.6.0_windows.exe
然后安装位置:

C:\NVIDIA\cuda126
C:\NVIDIA\cudnn9.6

系统环境变量设置如下:

CUDA_PATH=C:\NVIDIA\cuda126
CUDA_PATH_V12_6=C:\NVIDIA\cuda126
Path=C:\NVIDIA\cuda126;C:\NVIDIA\cuda126\bin;C:\NVIDIA\cuda126\libnvvp;C:\NVIDIA\cuda126\lib\x64;C:\NVIDIA\cudnn9.6\bin\12.6;C:\NVIDIA\cudnn9.6\lib\12.6\x64;...

安装 CUDA 时,不要勾选(名字记不清了,大概意思):

Nsight SVE
Cuda Visual Studio 整合

安装完毕测试:

$ nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Oct_30_01:18:48_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0

$ nvidia-smi

    Sat Apr  5 16:43:53 2025+-----------------------------------------------------------------------------------------+| NVIDIA-SMI 561.17                 Driver Version: 561.17         CUDA Version: 12.6     ||-----------------------------------------+------------------------+----------------------+| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC || Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. ||                                         |                        |               MIG M. ||=========================================+========================+======================||   0  NVIDIA GeForce GTX 1650      WDDM  |   00000000:01:00.0 Off |                  N/A || N/A   56C    P8              4W /   35W |      81MiB /   4096MiB |      0%      Default ||                                         |                        |                  N/A |+-----------------------------------------+------------------------+----------------------+

说明cuda显卡驱动和开发环境安装成功。

安装 pytorch

访问 PyTorch官网 https://pytorch.org/get-started/locally/,选择下图橙色所示部分,注意安装的Python和CUDA版本。

在这里插入图片描述打开 mingw64 命令行工具窗口,运行下面命令:

$ conda config --set show_channel_urls yes
$ conda config --set always_yes yes
# 默认重试次数为 30
$ conda config --set remote_max_retries 30
# 连接超时$ conda config --set remote_connect_timeout_secs 600
# 读取超时$ conda config --set remote_read_timeout_secs 1200
$ conda activate pytorch_env
$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

漫长的等待之后安装成功。

Downloading https://download.pytorch.org/whl/cu126/torch-2.6.0%2Bcu126-cp310-cp310-win_amd64.whl (2496.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 GB 236.1 kB/s eta 0:00:00
Downloading https://download.pytorch.org/whl/cu126/torchaudio-2.6.0%2Bcu126-cp310-cp310-win_amd64.whl (4.2 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 276.7 kB/s eta 0:00:00
Downloading https://download.pytorch.org/whl/fsspec-2024.6.1-py3-none-any.whl (177 kB)
Installing collected packages: sympy, fsspec, torch, torchvision, torchaudioAttempting uninstall: sympyFound existing installation: sympy 1.13.3Uninstalling sympy-1.13.3:Successfully uninstalled sympy-1.13.3Attempting uninstall: torchFound existing installation: torch 2.5.1Uninstalling torch-2.5.1:Successfully uninstalled torch-2.5.1
Successfully installed fsspec-2024.6.1 sympy-1.13.1 torch-2.6.0+cu126 torchaudio-2.6.0+cu126 torchvision-0.21.0+cu126
(pytorch_env)

编写一个测试文件:check_pytorch_env.py

import torchprint(torch.__version__)          # 查看 PyTorch 版本
print(torch.cuda.is_available())  # 输出 True 表示 CUDA 可用
print(torch.cuda.get_device_name(0))  # 显示 GPU 型号(如 NVIDIA RTX 3090)

运行测试:

$ python check_pytorch_env.py

2.6.0+cu126
True
NVIDIA GeForce GTX 1650
(pytorch_env)

说明 pytorch+cuda+gpu 安装成功。

安装 hugging-face

在安装好 PyTorch 后,安装 Hugging Face 的 transformers 库(核心工具库)和其他相关依赖的步骤如下。

系统环境变量增加:

HF_ENDPOINT=https://hf-mirror.com            # 模型下载网站
HF_HOME=D:\huggingface                       # hf 主目录。下载缓存目录自动在: $HF_HOME/hub
HF_MODELS=D:\huggingface\models              # 模型保存的本地目录
HF_HUB_DISABLE_SYMLINKS_WARNING=1

完整安装命令:

$ conda activate pytorch_env
$ pip3 install transformers datasets tokenizers accelerate peft safetensors soundfile librosa Pillow huggingface_hub python-dotenv

说明:

  • transformers(模型加载与推理):支持加载预训练模型(如 BERT、GPT、T5)、进行文本生成、分类、翻译等任务。
  • datasets(数据集加载与处理):快速加载和处理 NLP、CV、语音等公开数据集(如 GLUE、SQuAD)。
  • tokenizers(高性能分词工具):用于文本分词(支持 BPE、WordPiece 等算法),比 transformers 内置分词器更快。
  • huggingface_hub:通过镜像站下载模型:huggingface-cli download --resume-download --cache-dir “本地路径” 模型名称
  • python-dotenv:读取 .env 保存的环境变量

可选:

  • accelerate(分布式训练):加速库。简化多 GPU/TPU 训练代码,支持混合精度训练。
  • evaluate:模型评估库。提供标准评估指标(如准确率、F1、BLEU)。
  • peft:模型压缩库。支持参数高效微调(如 LoRA、Prefix Tuning)。
  • safetensors:模型序列化库。安全高效的模型权重序列化格式,替代传统 pickle。
  • soundfile、librosa:音频处理
  • Pillow:图像处理

编写一个测试文件:check_huggingface.py

	import transformersfrom transformers import pipeline# 应输出版本号(如 4.50.3)print(transformers.__version__)# 示例:情感分析管道classifier = pipeline("sentiment-analysis")result = classifier("Hugging Face is amazing!")print(result)  # 输出示例:[{'label': 'POSITIVE', 'score': 0.9998}]

运行测试:

$ python check_huggingface.py

报错。因为 https://huggingface.co 无法访问,所以需要使用Hugging Face Pipeline在本地运行模型。模型下载脚本文件:
$HF_HOME/scriptes/download_models.py

import os
import transformers
from transformers import AutoModelForSequenceClassification, AutoTokenizerhf_models_dir = os.getenv("HF_MODELS")
# 指定模型名称
model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
local_dir = os.path.join(hf_models_dir, "bert-base-multilingual-uncased-sentiment")print("local_dir=", local_dir)
# 下载模型和分词器
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# 保存到本地
model.save_pretrained(local_dir)
tokenizer.save_pretrained(local_dir)

执行上面的脚本: H F _ H O M E / s c r i p t e s / d o w n l o a d _ m o d e l s . p y ,模型下载到本地目录: HF\_HOME/scriptes/download\_models.py,模型下载到本地目录: HF_HOME/scriptes/download_models.py,模型下载到本地目录:HF_MODELS/bert-base-multilingual-uncased-sentiment

情感分析测试 sentiment-analysis.py:

import os
from transformers import pipeline# D:\huggingface\models
hf_models_dir = os.environ["HF_MODELS"]print("hf_models_dir=", hf_models_dir)# 加载本地模型
classifier = pipeline("sentiment-analysis",model = os.path.join(hf_models_dir, "bert-base-multilingual-uncased-sentiment"),tokenizer= os.path.join(hf_models_dir, "bert-base-multilingual-uncased-sentiment")
)print("classifier ok")# 测试文本
test_lines = ["傻!","关税战没有赢家","中国国必胜。yeah yeah"
]for l in test_lines:result = classifier(l)print(l, result)print("test exit ok")

执行:python sentiment-analysis.py

http://www.dtcms.com/wzjs/111854.html

相关文章:

  • 民权做网站seo优化师培训
  • 网站编程技术 吉林出版集团股份有限公司长春建站服务
  • 做网站的服务器带宽一般多少南京疫情最新消息
  • 网站域名.xin促销方法100种
  • 做装修网站制作网站的网址
  • 公司和个人均不能备案论坛类网站网站建设流程步骤
  • 网站使用字体广告联盟接单赚钱平台
  • 网站免费建立谷歌外贸seo
  • 深圳人才一体化综合服务平台郑州seo教程
  • 做网站的工具有哪些上海关键词排名优化公司
  • 网站制作多久百度首页关键词优化
  • 专做企业网站的seo资源咨询
  • 北仑做网站唐山网站建设方案优化
  • 网站目前如何做外链网络整合营销案例
  • 大浪网云南seo
  • 电影网站cpa怎么做网站规划与设计
  • 做蛋糕视频教学网站seo技术培训宁波
  • 网站建设思想重视不够广告设计网站
  • 网站建设需兰州seo推广
  • 手机端网站开发的意义排名前50名免费的网站
  • html个人主页源码网络优化工程师有前途吗
  • 济南做网站公司济南网络推广公司电话
  • 网站建设文编干净无广告的搜索引擎
  • 网站建设技术服务方案怎么在百度上发广告
  • 国内html5网站案例营销网站设计
  • 视频教育网站开发网络营销的主要传播渠道是
  • 欧美网站设计欣赏企业产品营销策划推广
  • 网站建设电话销售话术长沙seo优化排名推广
  • 模具外贸营销网站如何做怎么制作网页链接
  • 三都网站建设网站制作流程图