- open cmd as administrator
- wsl –install
- reboot
- wsl
- install CUDA toolkit
- wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
- ./Anaconda3-2022.10-Linux-x86_64.sh
- Reboot entire machine AGAIN
- mkdir gptj
- cd gptj
conda create -n gptj python=3.8
conda activate gptj
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
pip uninstall -y transformers && pip install --no-cache-dir https://github.com/deniskamazur/transformers/archive/gpt-j-8bit.zip
pip install bitsandbytes-cuda111
pip install datasets==1.16.1
- pip install torch==1.11.0+cu115 torchvision==0.12.0+cu115 -f https://download.pytorch.org/whl/torch_stable.html
import torch
import transformers
from transformers.models.gptj import GPTJForCausalLM
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = transformers.AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6b")
gpt = GPTJForCausalLM.from_pretrained(
"hivemind/gpt-j-6B-8bit", low_cpu_mem_usage=True
).to(device)
raw_text = open("prompts/delandzombie.txt", "r").read()
text = raw_text
prompt = tokenizer((raw_text), return_tensors="pt")
prompt = {key: value.to(device) for key, value in prompt.items()}
out = gpt.generate(
**prompt,
do_sample=True,
temperature=1.03,
top_k=500,
top_p=0.98,
max_new_tokens=200,
)
out = tokenizer.decode(out[0])
text = out
print(
"\n",
"\n",
str(text),
"\n",
"\n",
end="",
)
raw_text += text
output = open("out.txt", "a")
output.write(
str(text)
+ "\n"
+ "\n"
+ "------"
+ "\n"
+ "\n"
)
output.close()