devcon-mmdet3d

This text is also text!

ファイルの準備


Dockerfileの作成


Modify Dockerfile as follow.

[Dockerfile]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

# Install some basic utilities
RUN apt-get update && apt-get install wget -yq
RUN apt-get install build-essential g++ gcc -y
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install libgl1-mesa-glx libglib2.0-0 -y
RUN apt-get install openmpi-bin openmpi-common libopenmpi-dev libgtk2.0-dev git -y

# Install conda
ENV CONDA_DIR /opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_23.11.0-1-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda

ENV PATH=$CONDA_DIR/bin:$PATH
RUN conda install python=3.8

### Install pytorch
RUN pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

### Pip install mmcv-full in conda
RUN /opt/conda/bin/pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html

RUN /opt/conda/bin/pip install mmdet==2.14.0 \
mmsegmentation==0.14.1 \
timm \
Pillow==8.4.0 \
tqdm \
torchpack \
mpi4py==3.0.3 \
numba==0.48.0 \
nuscenes-devkit==1.1.9

RUN conda install conda-build pyyaml numpy ipython cython typing typing_extensions mkl mkl-include ninja &&\
/opt/conda/bin/conda clean -ya

WORKDIR /root/workspace

devcontainer.jsonの作成

Modify devcontainer.json as follow.

[devcontainer.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
"name": "bev-playground",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"remoteUser": "root",
"workspaceFolder": "/workspace",
"remoteEnv": {
"TRT_LIBPATH": "/usr/lib/x86_64-linux-gnu",
"TRT_OSSPATH": "/workspace/TensorRT"
},
"runArgs": [
"--gpus",
"all",
"--shm-size",
"16gb"
],
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind",
"source=${localWorkspaceFolder}/dataset/can_bus,target=/workspace/VAD/data/can_bus,type=bind",
"source=${localWorkspaceFolder}/dataset/nuscenes,target=/workspace/VAD/data/nuscenes,type=bind",
],
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python3"
}
}

Dockerビルド


VscodeでReopen containerをクリックして、コンテナをビルドし始めます。

mmdet3dインストール


コンテナでは、mmdet3dをインストールします。

[Dockerfile]
1
2
3
4
  git clone https://github.com/open-mmlab/mmdetection3d.git &&\
cd mmdetection3d &&\
git checkout -f v0.17.1 &&\
python setup.py develop

Troubleshooting


mmdet3dをインストールするとき、libやlibのバージョンが合わせない問題が発生しました。(更新予定)
以下のように修正してください。

1
2
3
4
5
6
7
scikit-image==0.21.0
networkx==3.1
pandas==2.0.3
numba==0.48.0
numpy==1.21.1
similaritymeasures==1.2.0
shaplely==1.8.5

vscode-devcon-1

This text is also text!

必要なツールのインストール


  • VSCode: 公式サイトからインストール
  • Docker Desktop: 公式サイトからインストール
  • VSCode拡張機能

プロジェクト構造の準備


1
2
3
4
5
6
7
project/
├── .devcontainer/
│ ├── devcontainer.json
│ ├── Dockerfile
├── src/
│ └── main.py
└── requirements.txt

各ファイルの作成


Dockerfileの作成

まず、Dockerfileを作成します。Docker imagesがビルドされます。

[dockerfile]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Dockerfile
FROM python:3.10-slim

# 必要なツールをインストール
RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

# ワークスペースを設定
WORKDIR /workspace

# Python環境をセットアップ
COPY requirements.txt /workspace/
RUN pip install --no-cache-dir -r requirements.txt

devcontainer.jsonの作成

次に、devcontainerからdockerイメージをビルドし、Containerを起動するためdevcontainer.jsonで設定します。

マウント設定もここで設定します。

1
2
3
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind"
]
[devcontainer.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// .devcontainer/devcontainer.json
{
"name": "Python DevContainer",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"settings": {
"python.pythonPath": "/usr/local/bin/python"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"forwardPorts": [8000],
"postCreateCommand": "pip install --no-cache-dir -r requirements.txt",
"remoteUser": "root",
"workspaceFolder": "/workspace",
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind"
]
}

launch.jsonの作成

Debuggerを使ってデバックするためlaunch.jsonを作成します。

[launch.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Docker Debug",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"console": "integratedTerminal",
"justMyCode": true
}
]
}

その他のファイルの作成

requirements.txtの作成

[requirements.txt]
1
2
3
4
5
requests==2.31.0      # HTTPリクエストを送信するためのライブラリ
numpy==1.26.0 # 数値計算ライブラリ
pandas==2.1.1 # データ分析ライブラリ
scipy==1.11.3 # 科学技術計算ライブラリ
matplotlib==3.8.0 # グラフ描画ライブラリ

src/main.pyの作成

今回デバックしたいpythonファイルを作成します。

まとめ


以上、Vscode + Devcontainerのdocker containerの中でデバック環境を構築することができました。
必要なLibについて、Dockerfilerequirements.txtを追加・修正してカスタマイズしてください。

create-hexo-website

Generate new article

Create new post

1
hexo new "first post"

Create a new page on Hexo or Algorithm.

1
2
hexo new page hexo
hexo new page algorithm

Run Hexo server locally

1
hexo server

Generate the Website

1
2
hexo clean
hexo generate

Deploy your Website to Github

Push source to public

1
hexo deploy 

Add underline of header

Add the commend in markdown

1
2
This text is also text! <!-- New line here... -->
---

add-mermaind

環境セットアップ

hexo-filter-mermaid-diagramsのインストール

1
npm install hexo-filter-mermaid-diagrams --save

Mermaidの_config.ymlの設定

1
2
3
4
5
mermaid:
enable: true
version: "7.1.2"
# Available themes: default | dark | forest | neutral
theme: default

Mermaidの読み込み

hexo-theme-icarus/layout/common/scripts.jsxに以下を追加する

1
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.4.0/mermaid.min.js"></script>

ダイアグラム図作成

フローチャート図

1
2
3
4
5
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
    click D "https://google.com";

シーケンス図

1
2
3
4
5
6
7
8
9
10
11
sequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts 
prevail... John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good!

ガンチャート図

1
2
3
4
5
6
7
8
9
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram to mermaid

section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
gantt
dateFormat  YYYY-MM-DD
title Adding GANTT diagram to mermaid

section A section
Completed task            :done,    des1, 2014-01-06,2014-01-08
Active task               :active,  des2, 2014-01-09, 3d
Future task               :         des3, after des2, 5d
Future task2               :         des4, after des3, 5d

クラス図

1
2
3
4
5
6
7
8
9
10
11
12
13
14
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label

Gitグラフ

1
2
3
4
5
6
7
8
9
10
gitGraph
commit
commit
branch develop
commit
commit
commit
checkout main
commit
commit
gitGraph
   commit
   commit
   branch develop
   commit
   commit
   commit
   checkout main
   commit
   commit

Quadrant Chart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
quadrantChart
title Reach and engagement of campaigns
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 We should expand
quadrant-2 Need to promote
quadrant-3 Re-evaluate
quadrant-4 May be improved
Campaign A: [0.3, 0.6]
Campaign B: [0.45, 0.23]
Campaign C: [0.57, 0.69]
Campaign D: [0.78, 0.34]
Campaign E: [0.40, 0.34]
Campaign F: [0.35, 0.78]

quadrantChart
    title Reach and engagement of campaigns
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 We should expand
    quadrant-2 Need to promote
    quadrant-3 Re-evaluate
    quadrant-4 May be improved
    Campaign A: [0.3, 0.6]
    Campaign B: [0.45, 0.23]
    Campaign C: [0.57, 0.69]
    Campaign D: [0.78, 0.34]
    Campaign E: [0.40, 0.34]
    Campaign F: [0.35, 0.78]

Pie chart diagrams

1
2
3
4
5
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15

pie title Pets adopted by volunteers
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15

フローチャート

flowchart 

A(開始)
B(終了)
処理1
C[処理2]
D{判断}
E[処理2-2]
F{{準備}}
G1[/外部データ<上にあると入力>/]
G2[/外部データ<下にあると出力>/]
H[[定義<マクロ>]]
I[(データベース)]
J1((結合子A))
J2((結合子A'))
K1[/ループ開始\]
K2[\ループ終了条件式/]

A --> F
F --> K1
K1 --> 処理1
処理1 --> D
D --> E & G1
E --> H
G1 --> C --> G2
G2 & H --> K2 --> B

H -.- J1
J2 --> マクロ内容開始 --- I --- マクロ内容終了 --> J2

install-hexo

Hexo インストール

1
2
3
hexo init <folder>
cd <folder>
npm install

hexo-theme-icarusのインストール

1
npm install -S hexo-theme-icarus hexo-renderer-inferno

_config.yml ファイル

1
theme: icarus

もしくは

1
hexo config theme icarus