diff --git a/.gitignore b/.gitignore
index 82e6e9e6..8acdb364 100644
--- a/.gitignore
+++ b/.gitignore
@@ -160,6 +160,8 @@ cython_debug/
.idea/
# custom .gitignore
+ms_cache/
+hf_cache/
cache/
config/
saves/
diff --git a/README.md b/README.md
index 80ab347f..f96bb0ef 100644
--- a/README.md
+++ b/README.md
@@ -422,16 +422,24 @@ For CUDA users:
```bash
cd docker/docker-cuda/
-docker-compose up -d
-docker-compose exec llamafactory bash
+docker compose up -d
+docker compose exec llamafactory bash
```
For Ascend NPU users:
```bash
cd docker/docker-npu/
-docker-compose up -d
-docker-compose exec llamafactory bash
+docker compose up -d
+docker compose exec llamafactory bash
+```
+
+For ROCm users:
+
+```bash
+cd docker/docker-rocm/
+docker compose up -d
+docker compose exec llamafactory bash
```
Build without Docker Compose
@@ -493,6 +501,34 @@ docker run -dit \
docker exec -it llamafactory bash
```
+For ROCm users:
+
+```bash
+docker build -f ./docker/docker-rocm/Dockerfile \
+ --build-arg INSTALL_BNB=false \
+ --build-arg INSTALL_VLLM=false \
+ --build-arg INSTALL_DEEPSPEED=false \
+ --build-arg INSTALL_FLASHATTN=false \
+ --build-arg PIP_INDEX=https://pypi.org/simple \
+ -t llamafactory:latest .
+
+docker run -dit \
+ -v ./hf_cache:/root/.cache/huggingface \
+ -v ./ms_cache:/root/.cache/modelscope \
+ -v ./data:/app/data \
+ -v ./output:/app/output \
+ -v ./saves:/app/saves \
+ -p 7860:7860 \
+ -p 8000:8000 \
+ --device=/dev/kfd \
+ --device=/dev/dri \
+ --shm-size 16G \
+ --name llamafactory \
+ llamafactory:latest
+
+docker exec -it llamafactory bash
+```
+
Details about volume
diff --git a/docker/docker-rocm/Dockerfile b/docker/docker-rocm/Dockerfile
new file mode 100644
index 00000000..a0c42d3b
--- /dev/null
+++ b/docker/docker-rocm/Dockerfile
@@ -0,0 +1,57 @@
+FROM hardandheavy/transformers-rocm:2.1.0
+
+# Define environments
+ENV MAX_JOBS=4
+ENV FLASH_ATTENTION_FORCE_BUILD=TRUE
+ENV VLLM_WORKER_MULTIPROC_METHOD=spawn
+
+# Define installation arguments
+ARG INSTALL_BNB=false
+ARG INSTALL_VLLM=false
+ARG INSTALL_DEEPSPEED=false
+ARG INSTALL_FLASHATTN=false
+ARG PIP_INDEX=https://pypi.org/simple
+
+# Set the working directory
+WORKDIR /app
+
+# Install the requirements
+COPY requirements.txt /app
+RUN pip config set global.index-url "$PIP_INDEX" && \
+ pip config set global.extra-index-url "$PIP_INDEX" && \
+ python -m pip install --upgrade pip && \
+ python -m pip install -r requirements.txt
+
+# Copy the rest of the application into the image
+COPY . /app
+
+# Install the LLaMA Factory
+RUN EXTRA_PACKAGES="metrics"; \
+ if [ "$INSTALL_BNB" == "true" ]; then \
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},bitsandbytes"; \
+ fi; \
+ if [ "$INSTALL_VLLM" == "true" ]; then \
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},vllm"; \
+ fi; \
+ if [ "$INSTALL_DEEPSPEED" == "true" ]; then \
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \
+ fi; \
+ pip install -e ".[$EXTRA_PACKAGES]"
+
+# Rebuild flash attention
+RUN pip uninstall -y transformer-engine flash-attn && \
+ if [ "$INSTALL_FLASHATTN" == "true" ]; then \
+ pip uninstall -y ninja && pip install ninja && \
+ pip install --no-cache-dir flash-attn --no-build-isolation; \
+ fi
+
+# Set up volumes
+VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]
+
+# Expose port 7860 for the LLaMA Board
+ENV GRADIO_SERVER_PORT 7860
+EXPOSE 7860
+
+# Expose port 8000 for the API service
+ENV API_PORT 8000
+EXPOSE 8000
diff --git a/docker/docker-rocm/docker-compose.yml b/docker/docker-rocm/docker-compose.yml
new file mode 100644
index 00000000..059d576f
--- /dev/null
+++ b/docker/docker-rocm/docker-compose.yml
@@ -0,0 +1,29 @@
+services:
+ llamafactory:
+ build:
+ dockerfile: ./docker/docker-rocm/Dockerfile
+ context: ../..
+ args:
+ INSTALL_BNB: false
+ INSTALL_VLLM: false
+ INSTALL_DEEPSPEED: false
+ INSTALL_FLASHATTN: false
+ PIP_INDEX: https://pypi.org/simple
+ container_name: llamafactory
+ volumes:
+ - ../../hf_cache:/root/.cache/huggingface
+ - ../../ms_cache:/root/.cache/modelscope
+ - ../../data:/app/data
+ - ../../output:/app/output
+ - ../../saves:/app/saves
+ ports:
+ - "7860:7860"
+ - "8000:8000"
+ ipc: host
+ tty: true
+ stdin_open: true
+ command: bash
+ devices:
+ - /dev/kfd:/dev/kfd
+ - /dev/dri:/dev/dri
+ restart: unless-stopped