mk99z commited on
Commit
3e6d526
·
verified ·
1 Parent(s): 29e08eb

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +29 -1
start.sh CHANGED
@@ -1,5 +1,11 @@
1
  #!/bin/bash
2
 
 
 
 
 
 
 
3
  # 检查是否存在Hugging Face token
4
  if [ ! -z "$HUGGINGFACE_TOKEN" ]; then
5
  echo "Setting up Hugging Face credentials..."
@@ -16,5 +22,27 @@ if [ -d "/workspace/android-project" ]; then
16
  fi
17
  fi
18
 
19
- # 保持容器运行
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  exec "$@"
 
1
  #!/bin/bash
2
 
3
+ # 设置错误处理
4
+ set -e
5
+
6
+ # 创建Hugging Face配置目录
7
+ mkdir -p ~/.huggingface
8
+
9
  # 检查是否存在Hugging Face token
10
  if [ ! -z "$HUGGINGFACE_TOKEN" ]; then
11
  echo "Setting up Hugging Face credentials..."
 
22
  fi
23
  fi
24
 
25
+ # 检查CUDA可用性
26
+ python3 -c "import torch; print('CUDA available:', torch.cuda.is_available())"
27
+
28
+ # 创建示例Python脚本
29
+ cat > /workspace/test_environment.py << EOL
30
+ from transformers import pipeline
31
+ import torch
32
+
33
+ print("PyTorch version:", torch.__version__)
34
+ print("CUDA available:", torch.cuda.is_available())
35
+ if torch.cuda.is_available():
36
+ print("CUDA device:", torch.cuda.get_device_name(0))
37
+
38
+ # 测试Hugging Face pipeline
39
+ classifier = pipeline("sentiment-analysis")
40
+ result = classifier("Hello, world!")
41
+ print("Test pipeline result:", result)
42
+ EOL
43
+
44
+ echo "Environment setup complete!"
45
+ echo "You can test the environment by running: python3 /workspace/test_environment.py"
46
+
47
+ # 执行传入的命令或启动bash
48
  exec "$@"