-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57a9208
commit d860796
Showing
11 changed files
with
1,055 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 1000 | ||
exclude = .git,__pycache__,docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Docker Build and Push to GHCR | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: false | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
if: github.event_name == 'push' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ghcr.io/${{ github.repository }}:latest . | ||
- name: Push Docker image | ||
if: github.event_name == 'push' | ||
run: | | ||
docker push ghcr.io/${{ github.repository }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Lint Python Code | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
flake8-lint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Run flake8 | ||
run: flake8 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM nvidia/cuda:12.6.2-cudnn-devel-ubuntu22.04 | ||
|
||
RUN apt-get update && apt-get install -y git curl python3-pip | ||
RUN git config --global --add safe.directory /app | ||
RUN python3 -m pip install --upgrade pip | ||
RUN python3 -m pip install poetry \ | ||
&& poetry config virtualenvs.create false | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry install --no-root | ||
|
||
COPY download_weight.py ./ | ||
RUN python3 download_weight.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import clip | ||
import torch | ||
|
||
device = "cuda" if torch.cuda.is_available() else "cpu" | ||
print("Detect device: ", device) | ||
model, preprocess = clip.load("ViT-B/32", device=device) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
cd /app | ||
poetry lock --no-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[tool.poetry] | ||
name = "lab_tool" | ||
version = "0.1.0" | ||
description = "research" | ||
authors = ["Taiga Takano <[email protected]>"] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.10,<3.12" | ||
flake8 = "7.1.1" | ||
torch = "2.5.1" | ||
torchvision = "0.20.1" | ||
torchaudio = "2.5.1" | ||
clip = { git = "https://github.com/openai/CLIP.git", rev = "dcba3cb" } | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# https://qiita.com/k_ikasumipowder/items/5e71208b7c7ae3e4fe7c | ||
|
||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
# Prevent running as root. | ||
if [[ $(id -u) -eq 0 ]]; then | ||
echo "This script cannot be executed with root privileges." | ||
echo "Please re-run without sudo and follow instructions to configure docker for non-root user if needed." | ||
exit 1 | ||
fi | ||
|
||
# Check if user can run docker without root. | ||
RE="\<docker\>" | ||
if [[ ! $(groups $USER) =~ $RE ]]; then | ||
echo "User |$USER| is not a member of the 'docker' group and cannot run docker commands without sudo." | ||
echo "Run 'sudo usermod -aG docker \$USER && newgrp docker' to add user to 'docker' group, then re-run this script." | ||
echo "See: https://docs.docker.com/engine/install/linux-postinstall/" | ||
exit 1 | ||
fi | ||
|
||
# Check if able to run docker commands. | ||
if [[ -z "$(docker ps)" ]] ; then | ||
echo "Unable to run docker commands. If you have recently added |$USER| to 'docker' group, you may need to log out and log back in for it to take effect." | ||
echo "Otherwise, please check your Docker installation." | ||
exit 1 | ||
fi | ||
|
||
PLATFORM="$(uname -m)" | ||
|
||
if [ $PLATFORM = "x86_64" ]; then | ||
echo "x86" | ||
docker pull ghcr.io/moriyalab/lab_tool:latest | ||
docker run -it --rm --gpus all --runtime nvidia --shm-size=32G -v $ROOT:/app -w /app --network host ghcr.io/moriyalab/clip_image2vec:latest /bin/bash | ||
else | ||
echo "Not Support Platform. Only support x86." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters