VenkateshRoshan commited on
Commit
0891867
·
1 Parent(s): 713dd69

serve file added

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. dockerfile +57 -18
  3. serve.sh +13 -0
app.py CHANGED
@@ -165,7 +165,7 @@ def create_chat_interface():
165
  if __name__ == "__main__":
166
  demo = create_chat_interface()
167
  demo.launch(
168
- share=True,
169
  server_name="0.0.0.0", # Makes the server accessible from other machines
170
  server_port=7860, # Specify the port
171
  debug=True
 
165
  if __name__ == "__main__":
166
  demo = create_chat_interface()
167
  demo.launch(
168
+ share=False,
169
  server_name="0.0.0.0", # Makes the server accessible from other machines
170
  server_port=7860, # Specify the port
171
  debug=True
dockerfile CHANGED
@@ -1,30 +1,69 @@
1
- # Use Python 3.10 slim as base image
2
- FROM python:3.10-slim
3
 
4
- # Set the working directory
5
- WORKDIR /app
6
 
7
- # Copy the current directory contents into the container at /app
8
- COPY . /app
9
 
10
- # Install dependencies
11
- RUN apt-get update && apt-get install -y \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  python3-pip \
13
- git
 
 
 
 
 
14
 
15
- # Install pip packages without caching
16
- RUN pip install --no-cache-dir --upgrade pip
17
  RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # # Copy .env file to the working directory
21
- # COPY .env /app/.env
 
22
 
23
- # # Set environment variables from .env file
24
- # ENV $(cat /app/.env | xargs)
25
 
26
- # Expose port 7860
27
  EXPOSE 7860
28
 
29
- # Run the application
30
- CMD ["python", "app.py"]
 
1
+ # # Use Python 3.10 slim as base image
2
+ # FROM python:3.10-slim
3
 
4
+ # # Set the working directory
5
+ # WORKDIR /app
6
 
7
+ # # Copy the current directory contents into the container at /app
8
+ # COPY . /app
9
 
10
+ # # Install dependencies
11
+ # RUN apt-get update && apt-get install -y \
12
+ # python3-pip \
13
+ # git
14
+
15
+ # # Install pip packages without caching
16
+ # RUN pip install --no-cache-dir --upgrade pip
17
+ # RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
18
+ # RUN pip install --no-cache-dir -r requirements.txt
19
+
20
+ # # # Copy .env file to the working directory
21
+ # # COPY .env /app/.env
22
+
23
+ # # # Set environment variables from .env file
24
+ # # ENV $(cat /app/.env | xargs)
25
+
26
+ # # Expose port 7860
27
+ # EXPOSE 7860
28
+
29
+
30
+
31
+ # # Run the application
32
+ # CMD ["python", "app.py"]
33
+
34
+ # Use NVIDIA CUDA base image
35
+ FROM nvidia/cuda:11.8.0-runtime-ubuntu20.04
36
+
37
+ # Set environment variables
38
+ ENV PYTHONUNBUFFERED=TRUE
39
+ ENV PYTHONDONTWRITEBYTECODE=TRUE
40
+ ENV PATH="/opt/conda/bin:${PATH}"
41
+
42
+ # Install system dependencies
43
+ RUN apt-get update && \
44
+ DEBIAN_FRONTEND=noninteractive apt-get install -y \
45
  python3-pip \
46
+ python3-dev \
47
+ git \
48
+ && rm -rf /var/lib/apt/lists/*
49
+
50
+ # Set up working directory
51
+ WORKDIR /opt/ml/code
52
 
53
+ # Copy requirements and install dependencies
54
+ COPY requirements.txt .
55
  RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
56
  RUN pip install --no-cache-dir -r requirements.txt
57
 
58
+ # Copy the application code and serve script
59
+ COPY app.py .
60
+ COPY serve .
61
 
62
+ # Make the serve script executable
63
+ RUN chmod +x serve
64
 
65
+ # Expose the Gradio port
66
  EXPOSE 7860
67
 
68
+ # Set entry point to the serve script
69
+ ENTRYPOINT ["./serve"]
serve.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set environment variables for SageMaker
4
+ if [ "${SM_MODEL_DIR}" = "" ]; then
5
+ export SM_MODEL_DIR=/opt/ml/model
6
+ fi
7
+
8
+ if [ "${SM_CHANNEL_TRAINING}" = "" ]; then
9
+ export SM_CHANNEL_TRAINING=/opt/ml/input/data/training
10
+ fi
11
+
12
+ # Start the Gradio app
13
+ exec python3 app.py