simple-llm-finetuner
simple-llm-finetuner copied to clipboard
add cpu support
This pull request introduces the --use_cpu
option to the main script, allowing users to run training and inference on the CPU. The --use_cpu
option can be specified when running the script to enable CPU usage. By default, the script will use the GPU (if available).
Changes:
- Added an argument parser for the
--use_cpu
option to specify CPU usage for training and inference. - Updated the
load_base_model
function to adjustload_in_8bit
,torch_dtype
, anddevice_map
based on theuse_cpu
argument. - Modified the
TrainingArguments
to setfp16
based on theuse_cpu
argument. - Removed the
.cuda()
call from thegenerate_text
function when using the CPU.
This update provides flexibility for users who want to run the script on systems without a GPU. The option to use the CPU can be helpful for testing, debugging, and using the script on machines with limited GPU resources.
Since I refactored the whole thing, you might need to adjust it a bit. Sorry
The most expected pull request for now) to be able to work with llm on laptops
I went through the latest code and seems like the updated code already takes care of running on cpu if cuda is unavailable. I believe the trainer should work out of the box on cpu now.
here: config.py - HAS_CUDA = torch.cuda.is_available() DEVICE = torch.device('cuda' if HAS_CUDA else 'cpu')
Let me know if otherwise.