jetson-examples 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,173 @@
1
+ #!/bin/bash
2
+
3
+ check_is_jetson_or_not() {
4
+ model_file="/proc/device-tree/model"
5
+
6
+ if [ -f "$model_file" ]; then
7
+ first_line=$(head -n 1 "$model_file")
8
+
9
+ if [[ "$first_line" == NVIDIA* ]]; then
10
+ echo "INFO: jetson machine confirmed..."
11
+ else
12
+ echo "WARNING: your machine maybe not support..."
13
+ exit 1
14
+ fi
15
+ else
16
+ echo "ERROR: only jetson support this..."
17
+ exit 1
18
+ fi
19
+ }
20
+ check_is_jetson_or_not
21
+
22
+ check_disk_space() {
23
+ directory="$1" # a directory
24
+ required_space_gb="$2" # how many GB we need
25
+
26
+ # get disk of directory
27
+ device=$(df -P "$directory" | awk 'NR==2 {print $1}')
28
+ echo $device
29
+
30
+ # get free space in KB
31
+ free_space=$(df -P "$device" | awk 'NR==2 {print $4}')
32
+ echo $free_space
33
+
34
+ # change unit to GB
35
+ free_space_gb=$(echo "scale=2; $free_space / 1024 / 1024" | bc)
36
+ echo $free_space_gb
37
+
38
+ # check and fast-fail
39
+ if (( $(echo "$free_space_gb >= $required_space_gb" | bc -l) )); then
40
+ echo "disk space ($1) enough, keep going."
41
+ else
42
+ echo "disk space ($1) not enough!! we need $2 GB!!"
43
+ exit 1
44
+ fi
45
+ }
46
+
47
+ echo "run example:$1"
48
+ BASE_PATH=/home/$USER/reComputer
49
+ echo "----example init----"
50
+ mkdir -p $BASE_PATH/
51
+ JETSON_REPO_PATH="$BASE_PATH/jetson-containers"
52
+ if [ -d $JETSON_REPO_PATH ]; then
53
+ echo "jetson-ai-lab existed."
54
+ else
55
+ echo "jetson-ai-lab does not installed. start init..."
56
+ cd $BASE_PATH/
57
+ git clone --depth=1 https://github.com/dusty-nv/jetson-containers
58
+ cd $JETSON_REPO_PATH
59
+ sudo apt update; sudo apt install -y python3-pip
60
+ pip3 install -r requirements.txt
61
+ fi
62
+ echo "----example start----"
63
+ cd $JETSON_REPO_PATH
64
+ case "$1" in
65
+ "llava")
66
+ ./run.sh $(./autotag llava) \
67
+ python3 -m llava.serve.cli \
68
+ --model-path liuhaotian/llava-v1.5-7b \
69
+ --image-file /data/images/hoover.jpg
70
+ ;;
71
+ "llava-v1.5-7b")
72
+ ./run.sh $(./autotag llava) \
73
+ python3 -m llava.serve.cli \
74
+ --model-path liuhaotian/llava-v1.5-7b \
75
+ --image-file /data/images/hoover.jpg
76
+ ;;
77
+ "llava-v1.6-vicuna-7b")
78
+ ./run.sh $(./autotag local_llm) \
79
+ python3 -m local_llm --api=mlc \
80
+ --model liuhaotian/llava-v1.6-vicuna-7b \
81
+ --max-context-len 768 \
82
+ --max-new-tokens 128
83
+ ;;
84
+ "Sheared-LLaMA-2.7B-ShareGPT")
85
+ ./run.sh $(./autotag local_llm) \
86
+ python3 -m local_llm.chat --api=mlc \
87
+ --model princeton-nlp/Sheared-LLaMA-2.7B-ShareGPT
88
+ ;;
89
+ "text-generation-webui")
90
+ # download llm model
91
+ ./run.sh --workdir=/opt/text-generation-webui $(./autotag text-generation-webui) /bin/bash -c \
92
+ 'python3 download-model.py --output=/data/models/text-generation-webui TheBloke/Llama-2-7b-Chat-GPTQ'
93
+ # run text-generation-webui
94
+ ./run.sh $(./autotag text-generation-webui)
95
+ ;;
96
+ "stable-diffusion-webui")
97
+ ./run.sh $(./autotag stable-diffusion-webui)
98
+ ;;
99
+ "nanoowl")
100
+ ./run.sh $(./autotag nanoowl) bash -c "ls /dev/video* && cd examples/tree_demo && python3 tree_demo.py ../../data/owl_image_encoder_patch32.engine"
101
+ ;;
102
+ "whisper")
103
+ ./run.sh $(./autotag whisper)
104
+ ;;
105
+ "nanodb")
106
+ # check data files TODO: support params to force download
107
+ DATA_PATH="$JETSON_REPO_PATH/data/datasets/coco/2017"
108
+ if [ ! -d $DATA_PATH ]; then
109
+ mkdir -p $DATA_PATH
110
+ fi
111
+ cd $DATA_PATH
112
+ # check val2017.zip
113
+ if [ ! -d "$DATA_PATH/val2017" ]; then
114
+ if [ ! -f "val2017.zip" ]; then
115
+ check_disk_space $DATA_PATH 1
116
+ wget http://images.cocodataset.org/zips/val2017.zip
117
+ else
118
+ echo "val2017.zip existed."
119
+ fi
120
+ check_disk_space $DATA_PATH 19
121
+ unzip val2017.zip && rm val2017.zip
122
+ else
123
+ echo "val2017/ existed."
124
+ fi
125
+ # check train2017.zip
126
+ if [ ! -d "$DATA_PATH/train2017" ]; then
127
+ if [ ! -f "train2017.zip" ]; then
128
+ check_disk_space $DATA_PATH 19
129
+ wget http://images.cocodataset.org/zips/train2017.zip
130
+ else
131
+ echo "train2017.zip existed."
132
+ fi
133
+ check_disk_space $DATA_PATH 19
134
+ unzip train2017.zip && rm train2017.zip
135
+ else
136
+ echo "train2017/ existed."
137
+ fi
138
+ if [ ! -d "$DATA_PATH/unlabeled2017" ]; then
139
+ # check unlabeled2017.zip
140
+ if [ ! -f "unlabeled2017.zip" ]; then
141
+ check_disk_space $DATA_PATH 19
142
+ wget http://images.cocodataset.org/zips/unlabeled2017.zip
143
+ else
144
+ echo "unlabeled2017.zip existed."
145
+ fi
146
+ check_disk_space $DATA_PATH 19
147
+ unzip unlabeled2017.zip && rm unlabeled2017.zip
148
+ else
149
+ echo "unlabeled2017/ existed."
150
+ fi
151
+
152
+ # check index files
153
+ INDEX_PATH="$JETSON_REPO_PATH/data/nanodb/coco/2017"
154
+ if [ ! -d $INDEX_PATH ]; then
155
+ cd $JETSON_REPO_PATH/data/
156
+ check_disk_space $JETSON_REPO_PATH 1
157
+ wget https://nvidia.box.com/shared/static/icw8qhgioyj4qsk832r4nj2p9olsxoci.gz -O nanodb_coco_2017.tar.gz
158
+ tar -xzvf nanodb_coco_2017.tar.gz
159
+ fi
160
+
161
+ # RUN
162
+ cd $JETSON_REPO_PATH
163
+ ./run.sh $(./autotag nanodb) \
164
+ python3 -m nanodb \
165
+ --path /data/nanodb/coco/2017 \
166
+ --server --port=7860
167
+ ;;
168
+ *)
169
+ echo "Unknown example"
170
+ # handle unknown
171
+ ;;
172
+ esac
173
+ echo "----example done----"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 luozhixin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.1
2
+ Name: jetson-examples
3
+ Version: 0.0.1
4
+ Summary: run AI on Jetson, all you need is reComputer
5
+ Author-email: luozhixin <zhixin.luo@seeed.cc>
6
+ Project-URL: Homepage, https://github.com/Seeed-Projects/jetson-examples
7
+ Project-URL: Issues, https://github.com/Seeed-Projects/jetson-examples/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ <div align="center">
16
+ <img alt="jetson" height="200px" src="https://avatars.githubusercontent.com/u/688117?s=200&v=4">
17
+ </div>
18
+
19
+ # jetson-examples
20
+
21
+ [![Discord](https://dcbadge.vercel.app/api/server/5BQCkty7vN?style=flat&compact=true)](https://discord.gg/5BQCkty7vN)
22
+
23
+ - run ai examples on jetson.
24
+ - all you need is `reComputer`.
25
+
26
+ ## Install
27
+
28
+ ```sh
29
+ pip install reComputer
30
+ ```
31
+
32
+ - [more installation methods](./docs/install.md)
33
+
34
+ ## Quickstart
35
+
36
+ To run and chat with [LLaVA](https://www.jetson-ai-lab.com/tutorial_llava.html):
37
+
38
+ ```sh
39
+ reComputer run llava
40
+ ```
41
+
42
+ ## Example list
43
+
44
+ reComputer supports a list of examples from [jetson-ai-lab](https://www.jetson-ai-lab.com/)
45
+
46
+ Here are some examples that can be run:
47
+
48
+ | Example | Type | Model/Data Size | Image Size | Command |
49
+ | ---------------------- | ------------------------ | --------------- | ---------- | --------------------------------------- |
50
+ | text-generation-webui | Text (LLM) | 3.9GB | 14.8GB | `reComputer run text-generation-webui` |
51
+ | LLaVA | Text + Vision (VLM) | 13GB | 14.4GB | `reComputer run llava` |
52
+ | stable-diffusion-webui | Image Generation | 3.97G | 7.3GB | `reComputer run stable-diffusion-webui` |
53
+ | nanoowl | Vision Transformers(ViT) | 613MB | 15.1GB | `reComputer run nanoowl` |
54
+ | nanodb | Vector Database | 76GB | 7.0GB | `reComputer run nanodb` |
55
+ | whisper | Audio | 1.5GB | 6.0GB | `reComputer run whisper` |
56
+
57
+ > Note: You should have enough space to run example, like `LLaVA`, at least `27.4GB` totally
58
+
59
+ More Examples can be found [examples.md](./docs/examples.md)
60
+
61
+ ## TODO List
62
+
63
+ - [ ] check disk space enough or not before run
64
+ - [ ] allow to setting some configs, such as `BASE_PATH`
65
+ - [ ] detect host environment and install what we need
66
+ - [ ] support jetson-containers update
67
+ - [ ] all type jetson support checking list
68
+ - [ ] better table to show example's difference
69
+ - [ ] try jetpack 6.0
@@ -0,0 +1,9 @@
1
+ jetson_examples-0.0.1.data/data/scripts/run.sh,sha256=URYwn-EKgLolwNorU-d_LlaZC925sYg7nZO-guOcAsQ,5617
2
+ reComputer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ reComputer/main.py,sha256=K-ZpxttBOmEdLKyy6fIN8K4EMJ48dVIN88WvbWioB4Q,1109
4
+ jetson_examples-0.0.1.dist-info/LICENSE,sha256=ac_LOi8ChcJhymEfBulX98Y06wTI2IMcQnqCXZ5yay4,1066
5
+ jetson_examples-0.0.1.dist-info/METADATA,sha256=K3QgJ1VeZ_wPKNc3Pb_GtGV4WoilakN8vbs8uHY9aX4,2746
6
+ jetson_examples-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
+ jetson_examples-0.0.1.dist-info/entry_points.txt,sha256=5-OdcBifoDjVXE9KjNoN6tQa8l_XSXhdbBEgL2hxeDM,58
8
+ jetson_examples-0.0.1.dist-info/top_level.txt,sha256=SI-liiUOkoGwOJfMP7d7k63JKgdcbiEj6DEC8QIKI90,11
9
+ jetson_examples-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ reComputer = reComputer.main:run_script
@@ -0,0 +1 @@
1
+ reComputer
reComputer/__init__.py ADDED
File without changes
reComputer/main.py ADDED
@@ -0,0 +1,42 @@
1
+ import os
2
+ import subprocess
3
+ import sys
4
+
5
+
6
+ def get_installation_path():
7
+ script_path = os.path.abspath(sys.argv[0])
8
+ installation_path = os.path.dirname(script_path)
9
+ print("installation_path:", installation_path)
10
+ return installation_path
11
+
12
+
13
+ def run_script():
14
+ # TODO: maybe use python instead of shell is better
15
+ if len(sys.argv) == 3:
16
+ if sys.argv[1] == "run":
17
+ run_example()
18
+ else:
19
+ print("Only Support `run` for now. try `reComputer run llava` .")
20
+ elif len(sys.argv) == 2:
21
+ if sys.argv[1] == "check":
22
+ check()
23
+ else:
24
+ print("Only Support `check` for now. try `reComputer check` .")
25
+ else:
26
+ print("Error Usage! try `reComputer run xxx` .")
27
+
28
+
29
+ def run_example():
30
+ installation_path = get_installation_path()
31
+ runner_script = os.path.join(installation_path, "..", "scripts", "run.sh")
32
+ subprocess.run(["bash", runner_script, sys.argv[2]])
33
+
34
+
35
+ def check():
36
+ # TODO: do some real check
37
+ subprocess.run(["python", "-V"])
38
+ subprocess.run(["python3", "-V"])
39
+
40
+
41
+ if __name__ == "__main__":
42
+ pass