-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_hf.sh
More file actions
49 lines (41 loc) Β· 1.62 KB
/
setup_hf.sh
File metadata and controls
49 lines (41 loc) Β· 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Hugging Face Setup Script
# This script sets up Hugging Face authentication for accessing gated models
echo "π Setting up Hugging Face authentication..."
# Load environment variables from .env file if it exists
if [ -f ".env" ]; then
echo "π Loading environment variables from .env file..."
export $(grep -v '^#' .env | xargs)
echo "β
Environment variables loaded from .env file!"
else
echo "β οΈ No .env file found. Please create one with your Hugging Face token."
echo "π Create a .env file with:"
echo "HUGGINGFACE_HUB_TOKEN=your_token_here"
exit 1
fi
# Check if token is set
if [ -z "$HUGGINGFACE_HUB_TOKEN" ] || [ "$HUGGINGFACE_HUB_TOKEN" = "your_token_here" ]; then
echo "β No valid Hugging Face token found in environment variables."
echo "π Please set HUGGINGFACE_HUB_TOKEN in your .env file"
exit 1
fi
echo "β
Hugging Face token loaded from environment variables!"
# Verify the token is working
echo "π Verifying authentication..."
python -c "
import os
from huggingface_hub import whoami
try:
user_info = whoami()
print(f'β
Successfully authenticated as: {user_info[\"name\"]}')
print(f'π§ Email: {user_info.get(\"email\", \"Not provided\")}')
except Exception as e:
print(f'β Authentication failed: {e}')
print('Please check your token and try again.')
"
echo ""
echo "π You can now run your training script:"
echo "./venv/bin/python -m torch.distributed.run --nproc_per_node=1 train_fsdp_hf.py"
echo ""
echo "π‘ To make this permanent, add this line to your ~/.bashrc:"
echo "export HUGGINGFACE_HUB_TOKEN=\"your_token_here\""