Skip to content

Commit

Permalink
support 3rd party test
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnXuan committed Aug 11, 2024
1 parent aa6a774 commit 0798121
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM oneflowinc/oneflow:0.9.1.dev20240203-cuda11.8

RUN python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

COPY requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --no-cache-dir -r /tmp/requirements.txt

RUN python3 -m pip install --pre oneflow -f https://oneflow-staging.oss-cn-beijing.aliyuncs.com/branch/master/cu118

WORKDIR /workspace

RUN rm /tmp/requirements.txt
14 changes: 14 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## cv_cls_test.sh

### 介绍
`cv_cls_test.sh` 是一个用于处理 `cv/classification` 目录下子目录的 Bash 脚本。根据用户提供的参数,该脚本可以对所有子目录、随机选取的子目录或前 n 个子目录进行操作。

### 脚本功能
1. **复制子目录**:将指定的子目录内容复制到 `/workspace/temp_model` 目录下。
2. **进入工作目录**:进入 `/workspace/temp_model` 目录。
3. **运行脚本**:执行该目录下的脚本(`infer.sh`缺省脚本)。

### 使用方法

```bash
./cv_cls_test.sh {all|random|n} {infer.sh|train.sh}
5 changes: 5 additions & 0 deletions test/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
IMAGE_NAME="oneflow_comodels_test:0.1"

docker build -t $IMAGE_NAME .

58 changes: 58 additions & 0 deletions test/cv_cls_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

EXEC=${2:-infer.sh}
SUB_DIR_PATH="/workspace/CoModels/cv/classification"
WORKSPACE="/workspace/temp_model"

if [ $# -ne 1 ]; then
echo "Usage: $0 {all|random|n}"
exit 1
fi

option="$1"

subdirs=($(find "$SUB_DIR_PATH" -mindepth 1 -maxdepth 1 -type d))

process_subdir() {
local dir="$1"

rm -rf "$WORKSPACE"
mkdir -p "$WORKSPACE"

cp -rL "$dir"/* "$WORKSPACE"

cd "$WORKSPACE"

if [ -f "./$EXEC" ]; then
bash ./$EXEC
else
echo "$EXEC not found in $WORKSPACE"
fi

cd - > /dev/null
}

case "$option" in
"all")
for dir in "${subdirs[@]}"; do
process_subdir "$dir"
done
;;
"random")
random_index=$((RANDOM % ${#subdirs[@]}))
process_subdir "${subdirs[$random_index]}"
;;
[0-9]*)
n="$option"
for ((i=0; i<n && i<${#subdirs[@]}; i++)); do
process_subdir "${subdirs[$i]}"
done
;;
*)
echo "Invalid option: $option"
echo "Usage: $0 {all|random|n}"
exit 1
;;
esac

echo "All operations completed."
60 changes: 60 additions & 0 deletions test/cv_det_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

EXEC=${2:-infer.sh}
SUB_DIR_PATH="/workspace/CoModels/cv/detection"
WORKSPACE="/workspace/temp_model"

if [ $# -ne 1 ]; then
echo "Usage: $0 {all|random|n}"
exit 1
fi

option="$1"

subdirs=($(find "$SUB_DIR_PATH" -mindepth 1 -maxdepth 1 -type d))

process_subdir() {
local dir="$1"

rm -rf "$WORKSPACE"
mkdir -p "$WORKSPACE"

cp -rL "$dir"/* "$WORKSPACE"
cp -rL "$SUB_DIR_PATH/retinanet_resnet50_fpn" "$WORKSPACE"
cp -rL "$SUB_DIR_PATH/fcos_resnet50_fpn" "$WORKSPACE"

cd "$WORKSPACE"

if [ -f "./$EXEC" ]; then
bash ./$EXEC
else
echo "$EXEC not found in $WORKSPACE"
fi

cd - > /dev/null
}

case "$option" in
"all")
for dir in "${subdirs[@]}"; do
process_subdir "$dir"
done
;;
"random")
random_index=$((RANDOM % ${#subdirs[@]}))
process_subdir "${subdirs[$random_index]}"
;;
[0-9]*)
n="$option"
for ((i=0; i<n && i<${#subdirs[@]}; i++)); do
process_subdir "${subdirs[$i]}"
done
;;
*)
echo "Invalid option: $option"
echo "Usage: $0 {all|random|n}"
exit 1
;;
esac

echo "All operations completed."
21 changes: 21 additions & 0 deletions test/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

current_dir=$(dirname "$(realpath "$0")")
parent_dir=$(dirname "$current_dir")

docker run -it --rm --runtime=nvidia --privileged \
--network host --gpus=all \
--ipc=host \
-v /data:/data \
-v /data/dataset/coco:/dataset/mscoco_2017 \
-v $parent_dir:/workspace/CoModels \
-v $parent_dir/cached_models:/root/.oneflow \
-w /workspace \
oneflow_comodels_test:0.1 \
bash
#docker.io/oneflowinc/onediff:cu121 \
#comodels_test:latest \
#registry.cn-beijing.aliyuncs.com/oneflow/oneflow:nightly-cuda11.8 \
#triton_trt_llm:latest \
#docker.io/tensorrt_llm/release:latest \

11 changes: 11 additions & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
click == 8.1.7
omegaconf == 2.1.0
matplotlib
Pillow
opencv-python
scikit-learn
scipy==1.7.1
yacs
flowvision
termcolor
pycocotools

0 comments on commit 0798121

Please sign in to comment.