简体   繁体   English

使用 GPU 进行 HuggingFace 训练

[英]HuggingFace Training using GPU

Based on HuggingFace script to train a transformers model from scratch.基于HuggingFace 脚本从头开始训练一个变形金刚 model。 I run:我跑:

python3 run_mlm.py \
--dataset_name wikipedia \
--tokenizer_name roberta-base \
--model_type roberta \
--dataset_config_name 20200501.en \
--do_train \
--do_eval \
--learning_rate 1e-5 \
--num_train_epochs 5 \
--save_steps 5000 \
--warmup_steps=10000 \ 
--seed 666 \
--gradient_accumulation_steps=4 \ 
--output_dir models/mlm_wikipedia_scratch/ \
--per_gpu_train_batch_size 8

I don't understand why I can't see my python3 process on GPU running nvidia-smi Here a screen:我不明白为什么在运行nvidia-smi的 GPU 上看不到我的 python3 进程这里是一个屏幕: 顶部 |英伟达-smi |训练脚本

You have to make sure the followings are correct:您必须确保以下内容是正确的:

  1. GPU is correctly installed on your environment GPU 已正确安装在您的环境中
In [1]: import torch
In [2]: torch.cuda.is_available()
Out[2]: True
  1. Specify the GPU you want to use:指定您要使用的 GPU:
export CUDA_VISIBLE_DEVICES=X        # X = 0, 1 or 2
echo $CUDA_VISIBLE_DEVICES           # Testing: Should display the GPU you set

Run the script again and it should work.再次运行脚本,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM