Search code examples
python-3.xpytorchanacondallama

llama2 running pytorch produces a "failed to create process"


CONTEXT

  1. I am trying to run llama2 on my local machine.

  2. I have followed the documentation available on the github repository

https://github.com/facebookresearch/llama

thank you in advance for your support

what did I do?

  1. install anaconda
  2. clone the llama repository

https://github.com/facebookresearch/llama

  1. download the models

  2. create a virtual environment named llama2

  3. install pytorch on Anaconda

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

  1. install local components

pip install -e .

  1. executed the following command line
torchrun 
--nproc_per_node 1 example_text_completion.py 
--ckpt_dir llama-2-7b-chat/
--tokenizer_path tokenizer.model 
--max_seq_len 512 --max_batch_size 6

the error

failed to create process.


Solution

  • root cause

    the error comes from an incorrect-or-missing update of the torchrun-script.py

    how to correct the issue

    1. edit the file

    C:\Apps\Anaconda3\envs\[YOUR ENVIRONMENT]\Scripts\torchrun-script.py

    1. replace the first line with

    #!c:\Apps\Anaconda3\envs\[YOUR ENVIRONMENT]\python.exe

    1. save the file

    voilà, it works!