seungheondoh commited on
Commit
c098ff5
·
1 Parent(s): 3ecd1b9

first commit

Browse files
Files changed (3) hide show
  1. README.md +10 -0
  2. script/fetch_data.sh +10 -0
  3. script/virtualenv.sh +112 -0
README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Cloud Server Setup Documentation
2
+
3
+ This repository contains scripts and documentation for setting up a machine learning cloud server environment with PyTorch, Flash Attention, and Hugging Face tools.
4
+
5
+ ## System Requirements
6
+
7
+ - A Linux-based cloud server (Ubuntu 20.04+ recommended)
8
+ - At least 16GB RAM (32GB+ recommended for larger models)
9
+ - CUDA-compatible GPU (for PyTorch GPU acceleration)
10
+ - Sufficient disk space (at least 100GB recommended)
script/fetch_data.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ HF_TOKEN="your_token"
2
+ DATADIR="/workspace/seungheon/dataset"
3
+ mkdir -p $DATADIR
4
+ huggingface-cli login --token $HF_TOKEN
5
+ git lfs install
6
+ git clone https://huggingface.co/datasets/seungheondoh/cmd-fma-metadata $DATADIR/fma
7
+ git clone https://huggingface.co/datasets/seungheondoh/cmd-musicnet-metadata $DATADIR/musicnet
8
+ git clone https://huggingface.co/datasets/seungheondoh/cmd-medleydb-metadata $DATADIR/medleydb
9
+ git clone https://huggingface.co/datasets/seungheondoh/cmd-moisesdb-metadata $DATADIR/moisesdb
10
+ git clone https://huggingface.co/datasets/seungheondoh/cmd-mtg_jamendo-metadata $DATADIR/mtg_jamendo
script/virtualenv.sh ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Cloud server setup script for ML environment
3
+ # Installs: Python venv, uv, PyTorch 2.6.0, flash-attn, and Hugging Face CLI
4
+
5
+ set -e # Exit immediately if a command exits with a non-zero status
6
+
7
+ # Update system packages
8
+ echo "Updating system packages..."
9
+ sudo apt update && sudo apt upgrade -y
10
+ # Install system dependencies
11
+ echo "Installing system dependencies..."
12
+ sudo apt install vim ffmpeg libsndfile1 git htop git-lfs -y
13
+
14
+ # Install Python 3.10
15
+ echo "Installing Python 3.10..."
16
+ sudo apt install python3.10 python3.10-venv -y
17
+
18
+ # Check if Python 3.10 is installed
19
+ if ! command -v python3.10 &> /dev/null; then
20
+ echo "Failed to install Python 3.10. Please check your system and try again."
21
+ exit 1
22
+ fi
23
+
24
+ # Get Python version
25
+ PYTHON_VERSION=$(python3.10 --version | awk '{print $2}')
26
+ echo "Using Python version: ${PYTHON_VERSION}"
27
+
28
+ # Check for CUDA
29
+ if command -v nvidia-smi &> /dev/null; then
30
+ echo "NVIDIA GPU detected. Will install CUDA-enabled PyTorch."
31
+ CUDA_AVAILABLE=1
32
+ CUDA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | head -n 1)
33
+ echo "CUDA Driver Version: ${CUDA_VERSION}"
34
+ else
35
+ echo "No NVIDIA GPU detected. Will install CPU-only PyTorch."
36
+ CUDA_AVAILABLE=0
37
+ fi
38
+
39
+ # Create a virtual environment if it doesn't exist
40
+ if [ ! -d "venv" ]; then
41
+ echo "Creating Python virtual environment..."
42
+ python3.10 -m venv venv
43
+ else
44
+ echo "Virtual environment already exists."
45
+ fi
46
+
47
+ # Upgrade pip
48
+ echo "Upgrading pip..."
49
+ pip install --upgrade pip
50
+
51
+ # Install uv
52
+ echo "Installing uv package manager..."
53
+ curl -LsSf https://astral.sh/uv/install.sh | sh
54
+
55
+ # Start uv virtualenv
56
+ echo "Starting uv virtualenv..."
57
+ uv venv .venv
58
+ source .venv/bin/activate
59
+
60
+ # Ensure uv is in PATH
61
+ export PATH="$HOME/.cargo/bin:$PATH"
62
+ # Get CUDA version number if available
63
+ if [ "$CUDA_AVAILABLE" -eq 1 ]; then
64
+ CUDA_VERSION_NUM=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | head -n 1 | cut -d'.' -f1)
65
+ # Map CUDA driver version to PyTorch CUDA version
66
+ if [ "$CUDA_VERSION_NUM" -ge 535 ]; then
67
+ PYTORCH_CUDA="cu124" # CUDA 12.4
68
+ elif [ "$CUDA_VERSION_NUM" -ge 530 ]; then
69
+ PYTORCH_CUDA="cu121" # CUDA 12.1
70
+ elif [ "$CUDA_VERSION_NUM" -ge 520 ]; then
71
+ PYTORCH_CUDA="cu118" # CUDA 11.8
72
+ elif [ "$CUDA_VERSION_NUM" -ge 510 ]; then
73
+ PYTORCH_CUDA="cu117" # CUDA 11.7
74
+ else
75
+ echo "Warning: CUDA version may be too old. Defaulting to CPU version."
76
+ CUDA_AVAILABLE=0
77
+ fi
78
+ fi
79
+
80
+ # Install PyTorch 2.6.0
81
+ echo "Installing PyTorch 2.6.0..."
82
+ echo "Installing PyTorch with CUDA support (${PYTORCH_CUDA})..."
83
+ uv pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/${PYTORCH_CUDA}
84
+
85
+ # Install flash-attention
86
+ echo "Installing flash-attention..."
87
+ if [ "$CUDA_AVAILABLE" -eq 1 ]; then
88
+ # Install required dependencies for flash-attention
89
+ uv pip install packaging ninja
90
+ uv pip install flash-attn --no-build-isolation
91
+ else
92
+ echo "Warning: flash-attention requires CUDA. Skipping installation."
93
+ fi
94
+
95
+ # Install Hugging Face CLI and tools
96
+ echo "Installing Hugging Face CLI and tools..."
97
+ uv pip install huggingface_hub
98
+ # Verify installation
99
+ echo "Verifying installation..."
100
+ python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available())"
101
+
102
+ # Try importing flash-attention if CUDA is available
103
+ if [ "$CUDA_AVAILABLE" -eq 1 ]; then
104
+ python -c "import importlib.util; print('flash-attn available:', importlib.util.find_spec('flash_attn') is not None)"
105
+ fi
106
+ # Check for Hugging Face CLI
107
+ python -c "import huggingface_hub; print('Hugging Face Hub version:', huggingface_hub.__version__)"
108
+ echo "============================================================"
109
+ echo "Setup complete!"
110
+ echo "To activate this environment, run:"
111
+ echo "source venv/bin/activate"
112
+ echo "============================================================"