Compare commits

...

26 Commits

Author SHA1 Message Date
tuna2134@コマリン親衛隊
61914129dc Merge pull request #212 from neodyland/dependabot/cargo/ort-fd73862
Bump ort from `2d49e05` to `fd73862`
2025-06-16 18:01:48 +09:00
tuna2134@コマリン親衛隊
97c63a2e23 Merge pull request #213 from neodyland/dependabot/cargo/pyo3-0.25.1
Bump pyo3 from 0.25.0 to 0.25.1
2025-06-16 18:01:38 +09:00
dependabot[bot]
3475f47305 Bump pyo3 from 0.25.0 to 0.25.1
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.25.0 to 0.25.1.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/v0.25.1/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.25.0...v0.25.1)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-version: 0.25.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-16 08:20:04 +00:00
dependabot[bot]
5493b91a84 Bump ort from 2d49e05 to fd73862
Bumps [ort](https://github.com/pykeio/ort) from `2d49e05` to `fd73862`.
- [Release notes](https://github.com/pykeio/ort/releases)
- [Commits](2d49e052dc...fd738622d7)

---
updated-dependencies:
- dependency-name: ort
  dependency-version: fd738622d708d0b7da536812e20a9e63adeaa70d
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-16 08:16:14 +00:00
tuna2134@コマリン親衛隊
bca6d04e7b Merge pull request #211 from neodyland/dependabot/cargo/ort-2d49e05 2025-06-09 20:13:11 +09:00
dependabot[bot]
d44ebe873e Bump ort from d1ebde9 to 2d49e05
Bumps [ort](https://github.com/pykeio/ort) from `d1ebde9` to `2d49e05`.
- [Release notes](https://github.com/pykeio/ort/releases)
- [Commits](d1ebde95d3...2d49e052dc)

---
updated-dependencies:
- dependency-name: ort
  dependency-version: 2d49e052dc14134e7c28a7b3e0878870710cd759
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 08:04:14 +00:00
tuna2134@コマリン親衛隊
96b53d42cd Merge pull request #210 from neodyland/dependabot/cargo/ort-d1ebde9 2025-06-02 17:24:06 +09:00
dependabot[bot]
9765ef51d2 Bump ort from 4745bb3 to d1ebde9
Bumps [ort](https://github.com/pykeio/ort) from `4745bb3` to `d1ebde9`.
- [Release notes](https://github.com/pykeio/ort/releases)
- [Commits](4745bb3a4a...d1ebde95d3)

---
updated-dependencies:
- dependency-name: ort
  dependency-version: d1ebde95d386513fea836593815e8f86f7b96a85
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 08:07:32 +00:00
tuna2134@コマリン親衛隊
e68f58d698 Fix year 2025-05-27 07:25:04 +09:00
tuna2134@コマリン親衛隊
2124fe4650 Merge pull request #207 from neodyland/dependabot/cargo/ort-4745bb3 2025-05-27 06:57:31 +09:00
tuna2134@コマリン親衛隊
0217c0a4d5 Merge pull request #205 from neodyland/dependabot/cargo/tokio-1.45.1 2025-05-27 06:57:06 +09:00
tuna2134@コマリン親衛隊
1de09597f5 Merge pull request #206 from neodyland/dependabot/cargo/pyo3-0.25.0 2025-05-27 06:56:53 +09:00
tuna2134@コマリン親衛隊
38d86c9249 Merge pull request #208 from neodyland/dependabot/cargo/npyz-0.8.4 2025-05-27 06:56:34 +09:00
dependabot[bot]
ddc132b27b Bump npyz from 0.8.3 to 0.8.4
Bumps [npyz](https://github.com/ExpHP/npyz) from 0.8.3 to 0.8.4.
- [Changelog](https://github.com/ExpHP/npyz/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ExpHP/npyz/compare/0.8.3...0.8.4)

---
updated-dependencies:
- dependency-name: npyz
  dependency-version: 0.8.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 21:53:38 +00:00
dependabot[bot]
558cd24677 Bump ort from 90afc70 to 4745bb3
Bumps [ort](https://github.com/pykeio/ort) from `90afc70` to `4745bb3`.
- [Release notes](https://github.com/pykeio/ort/releases)
- [Commits](90afc700d0...4745bb3a4a)

---
updated-dependencies:
- dependency-name: ort
  dependency-version: 4745bb3a4a1b5ab7f2c807b8989638627068cdf9
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 21:52:29 +00:00
dependabot[bot]
6657b06786 Bump pyo3 from 0.24.2 to 0.25.0
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.24.2 to 0.25.0.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.24.2...v0.25.0)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-version: 0.25.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 21:52:04 +00:00
dependabot[bot]
2a8c9bafde Bump tokio from 1.45.0 to 1.45.1
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.45.0 to 1.45.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.45.0...tokio-1.45.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.45.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 21:51:36 +00:00
tuna2134@コマリン親衛隊
d7065ac6eb Merge pull request #204 from neodyland/tuna2134-patch-2
add: dependabot
2025-05-27 06:48:32 +09:00
tuna2134@コマリン親衛隊
0b1dbe4991 Create dependabot.yml 2025-05-27 06:47:06 +09:00
googlefan256
1ad588bfcf hotfix: path miss 2025-05-10 11:33:07 +09:00
googlefan256
9733ba95fa fix: the unknown error 2025-05-09 20:28:04 +09:00
googlefan256
843c16995c fix: cuda typo 2025-05-09 20:19:30 +09:00
googlefan256
f0821ea957 Merge pull request #201 from neodyland/googlefan256/fix-lot
fix: lot of
2025-05-09 20:10:08 +09:00
googlefan256
abc9cec7c7 fix: reduced actions 2025-05-09 20:07:18 +09:00
googlefan256
19e6b7f0e6 fix: ci 2025-05-09 20:05:46 +09:00
googlefan256
451f4497b6 fix: lot of 2025-05-09 17:01:02 +09:00
28 changed files with 515 additions and 380 deletions

11
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View File

@@ -1,4 +1,4 @@
name: CI name: Build
on: on:
push: push:
@@ -6,7 +6,6 @@ on:
- main - main
tags: tags:
- '*' - '*'
pull_request:
workflow_dispatch: workflow_dispatch:
permissions: permissions:
@@ -29,7 +28,7 @@ jobs:
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: 3.x python-version: 3.x
- run: docker build . -f .github/workflows/CI.Dockerfile --tag ci - run: docker build . -f .github/workflows/build.Dockerfile --tag ci
- name: Build wheels - name: Build wheels
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1
with: with:
@@ -111,6 +110,7 @@ jobs:
with: with:
name: wheels-sdist name: wheels-sdist
path: ./crates/sbv2_bindings/dist path: ./crates/sbv2_bindings/dist
python-wheel: python-wheel:
name: Wheel Upload name: Wheel Upload
runs-on: ubuntu-latest runs-on: ubuntu-latest

26
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Lint
on:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
components:
- rustfmt
- clippy
steps:
- name: Setup
uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: ${{ matrix.components }}
- name: Format
if: ${{ matrix.components == 'rustfmt' }}
run: cargo fmt --all -- --check
- name: Lint
if: ${{ matrix.components == 'clippy' }}
run: cargo clippy --all-targets --all-features -- -D warnings

746
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
[workspace] [workspace]
resolver = "2" resolver = "3"
members = ["./crates/sbv2_api", "./crates/sbv2_core", "./crates/sbv2_bindings", "./crates/sbv2_wasm"] members = ["./crates/sbv2_api", "./crates/sbv2_core", "./crates/sbv2_bindings", "./crates/sbv2_wasm"]
[workspace.package] [workspace.package]
@@ -8,7 +8,7 @@ edition = "2021"
description = "Style-Bert-VITSの推論ライブラリ" description = "Style-Bert-VITSの推論ライブラリ"
license = "MIT" license = "MIT"
readme = "./README.md" readme = "./README.md"
repository = "https://github.com/tuna2134/sbv2-api" repository = "https://github.com/neodyland/sbv2-api"
documentation = "https://docs.rs/sbv2_core" documentation = "https://docs.rs/sbv2_core"
[workspace.dependencies] [workspace.dependencies]

View File

@@ -1,6 +1,7 @@
MIT License MIT License
Copyright (c) 2024 tuna2134 Copyright (c) 2024 tuna2134
Copyright (c) 2025- neodyland
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -17,7 +17,7 @@
## プログラミングに詳しくない方向け ## プログラミングに詳しくない方向け
[こちら](https://github.com/tuna2134/sbv2-gui?tab=readme-ov-file)を参照してください。 [こちら](https://github.com/tuna2134/sbv2-gui)を参照してください。
コマンドやpythonの知識なしで簡単に使えるバージョンです。(できることはほぼ同じ) コマンドやpythonの知識なしで簡単に使えるバージョンです。(できることはほぼ同じ)
@@ -75,7 +75,7 @@ CPUの場合は
```sh ```sh
docker run -it --rm -p 3000:3000 --name sbv2 \ docker run -it --rm -p 3000:3000 --name sbv2 \
-v ./models:/work/models --env-file .env \ -v ./models:/work/models --env-file .env \
ghcr.io/tuna2134/sbv2-api:cpu ghcr.io/neodyland/sbv2-api:cpu
``` ```
<details> <details>
@@ -90,7 +90,7 @@ CPUの場合は
```bash ```bash
docker run --platform linux/amd64 -it --rm -p 3000:3000 --name sbv2 \ docker run --platform linux/amd64 -it --rm -p 3000:3000 --name sbv2 \
-v ./models:/work/models --env-file .env \ -v ./models:/work/models --env-file .env \
ghcr.io/tuna2134/sbv2-api:cpu ghcr.io/neodyland/sbv2-api:cpu
``` ```
</details> </details>
@@ -99,7 +99,7 @@ CUDAの場合は
docker run -it --rm -p 3000:3000 --name sbv2 \ docker run -it --rm -p 3000:3000 --name sbv2 \
-v ./models:/work/models --env-file .env \ -v ./models:/work/models --env-file .env \
--gpus all \ --gpus all \
ghcr.io/tuna2134/sbv2-api:cuda ghcr.io/neodyland/sbv2-api:cuda
``` ```
### 起動確認 ### 起動確認

View File

@@ -16,7 +16,7 @@ env_logger.workspace = true
log = "0.4.22" log = "0.4.22"
sbv2_core = { version = "0.2.0-alpha6", path = "../sbv2_core", features = ["aivmx"] } sbv2_core = { version = "0.2.0-alpha6", path = "../sbv2_core", features = ["aivmx"] }
serde = { version = "1.0.210", features = ["derive"] } serde = { version = "1.0.210", features = ["derive"] }
tokio = { version = "1.40.0", features = ["full"] } tokio = { version = "1.45.1", features = ["full"] }
utoipa = { version = "5.0.0", features = ["axum_extras"] } utoipa = { version = "5.0.0", features = ["axum_extras"] }
utoipa-scalar = { version = "0.3.0", features = ["axum"] } utoipa-scalar = { version = "0.3.0", features = ["axum"] }

View File

@@ -53,12 +53,16 @@ struct SynthesizeRequest {
text: String, text: String,
ident: String, ident: String,
#[serde(default = "sdp_default")] #[serde(default = "sdp_default")]
#[schema(example = 0.0_f32)]
sdp_ratio: f32, sdp_ratio: f32,
#[serde(default = "length_default")] #[serde(default = "length_default")]
#[schema(example = 1.0_f32)]
length_scale: f32, length_scale: f32,
#[serde(default = "style_id_default")] #[serde(default = "style_id_default")]
#[schema(example = 0_i32)]
style_id: i32, style_id: i32,
#[serde(default = "speaker_id_default")] #[serde(default = "speaker_id_default")]
#[schema(example = 0_i64)]
speaker_id: i64, speaker_id: i64,
} }

View File

@@ -16,7 +16,7 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
ndarray.workspace = true ndarray.workspace = true
pyo3 = { version = "0.24.0", features = ["anyhow"] } pyo3 = { version = "0.25.1", features = ["anyhow"] }
sbv2_core = { path = "../sbv2_core", features = ["std"], default-features = false } sbv2_core = { path = "../sbv2_core", features = ["std"], default-features = false }
[features] [features]

View File

@@ -136,6 +136,7 @@ impl TTSModel {
/// ------- /// -------
/// voice_data : bytes /// voice_data : bytes
/// 音声データ /// 音声データ
#[allow(clippy::too_many_arguments)]
fn synthesize<'p>( fn synthesize<'p>(
&'p mut self, &'p mut self,
py: Python<'p>, py: Python<'p>,

View File

@@ -16,7 +16,7 @@ env_logger.workspace = true
hound = "3.5.1" hound = "3.5.1"
jpreprocess = { version = "0.12.0", features = ["naist-jdic"] } jpreprocess = { version = "0.12.0", features = ["naist-jdic"] }
ndarray.workspace = true ndarray.workspace = true
npyz = { version = "0.8.3", optional = true } npyz = { version = "0.8.4", optional = true }
num_cpus = "1.16.0" num_cpus = "1.16.0"
once_cell.workspace = true once_cell.workspace = true
ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.9", optional = true } ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.9", optional = true }

View File

@@ -5,21 +5,27 @@ use std::io::copy;
use std::path::PathBuf; use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
let static_path = home_dir().unwrap().join(".cache/sbv2/all.bin"); let static_dir = home_dir().unwrap().join(".cache/sbv2");
let static_path = static_dir.join("all.bin");
let out_path = PathBuf::from(&env::var("OUT_DIR").unwrap()).join("all.bin"); let out_path = PathBuf::from(&env::var("OUT_DIR").unwrap()).join("all.bin");
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
if static_path.exists() { if static_path.exists() {
if fs::hard_link(&static_path, &out_path).is_err() { println!("cargo:info=Dictionary file already exists, skipping download.");
fs::copy(static_path, out_path).unwrap();
};
} else { } else {
println!("cargo:warning=Downloading dictionary file..."); println!("cargo:warning=Downloading dictionary file...");
let mut response = let mut response =
ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin") ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin")
.call()?; .call()?;
let mut response = response.body_mut().as_reader(); let mut response = response.body_mut().as_reader();
let mut file = fs::File::create(&out_path)?; if !static_dir.exists() {
fs::create_dir_all(static_dir)?;
}
let mut file = fs::File::create(&static_path)?;
copy(&mut response, &mut file)?; copy(&mut response, &mut file)?;
} }
if !out_path.exists() && fs::hard_link(&static_path, &out_path).is_err() {
println!("cargo:warning=Failed to create hard link, copying instead.");
fs::copy(static_path, out_path)?;
}
Ok(()) Ok(())
} }

View File

@@ -14,11 +14,9 @@ pub fn predict(
"attention_mask" => TensorRef::from_array_view((vec![1, attention_masks.len() as i64], attention_masks.as_slice()))?, "attention_mask" => TensorRef::from_array_view((vec![1, attention_masks.len() as i64], attention_masks.as_slice()))?,
} }
)?; )?;
let output = outputs["output"] let output = outputs["output"]
.try_extract_tensor::<f32>()? .try_extract_array::<f32>()?
.into_dimensionality::<Ix2>()? .into_dimensionality::<Ix2>()?
.to_owned(); .to_owned();
Ok(output) Ok(output)
} }

View File

@@ -28,6 +28,8 @@ pub enum Error {
Base64Error(#[from] base64::DecodeError), Base64Error(#[from] base64::DecodeError),
#[error("other")] #[error("other")]
OtherError(String), OtherError(String),
#[error("Style error: {0}")]
StyleError(String),
} }
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;

View File

@@ -81,7 +81,7 @@ fn phone_tone_to_kana(phones: Vec<String>, tones: Vec<i32>) -> Vec<(String, i32)
let tones = &tones[1..]; let tones = &tones[1..];
let mut results = Vec::new(); let mut results = Vec::new();
let mut current_mora = String::new(); let mut current_mora = String::new();
for ((phone, next_phone), (&tone, &next_tone)) in phones for ((phone, _next_phone), (&tone, &next_tone)) in phones
.iter() .iter()
.zip(phones.iter().skip(1)) .zip(phones.iter().skip(1))
.zip(tones.iter().zip(tones.iter().skip(1))) .zip(tones.iter().zip(tones.iter().skip(1)))

View File

@@ -21,10 +21,7 @@ pub fn load_model<P: AsRef<[u8]>>(model_file: P, bert: bool) -> Result<Session>
#[cfg(feature = "cuda")] #[cfg(feature = "cuda")]
{ {
#[allow(unused_mut)] #[allow(unused_mut)]
let mut cuda = ort::execution_providers::CUDAExecutionProvider::default() let mut cuda = ort::execution_providers::CUDAExecutionProvider::default();
.with_conv_algorithm_search(
ort::execution_providers::cuda::CUDAExecutionProviderCuDNNConvAlgoSearch::Default,
);
#[cfg(feature = "cuda_tf32")] #[cfg(feature = "cuda_tf32")]
{ {
cuda = cuda.with_tf32(true); cuda = cuda.with_tf32(true);
@@ -101,11 +98,9 @@ pub fn synthesize(
"noise_scale" => noise_scale, "noise_scale" => noise_scale,
"noise_scale_w" => noise_scale_w, "noise_scale_w" => noise_scale_w,
})?; })?;
let audio_array = outputs["output"] let audio_array = outputs["output"]
.try_extract_tensor::<f32>()? .try_extract_array::<f32>()?
.into_dimensionality::<Ix3>()? .into_dimensionality::<Ix3>()?
.to_owned(); .to_owned();
Ok(audio_array) Ok(audio_array)
} }

View File

@@ -1,4 +1,4 @@
use crate::error::Result; use crate::error::{Error, Result};
use ndarray::{s, Array1, Array2}; use ndarray::{s, Array1, Array2};
use serde::Deserialize; use serde::Deserialize;
@@ -21,6 +21,18 @@ pub fn get_style_vector(
style_id: i32, style_id: i32,
weight: f32, weight: f32,
) -> Result<Array1<f32>> { ) -> Result<Array1<f32>> {
if style_vectors.shape().len() != 2 {
return Err(Error::StyleError(
"Invalid shape for style vectors".to_string(),
));
}
if style_id < 0 || style_id >= style_vectors.shape()[0] as i32 {
return Err(Error::StyleError(format!(
"Invalid style ID: {}. Max ID: {}",
style_id,
style_vectors.shape()[0] - 1
)));
}
let mean = style_vectors.slice(s![0, ..]).to_owned(); let mean = style_vectors.slice(s![0, ..]).to_owned();
let style_vector = style_vectors.slice(s![style_id as usize, ..]).to_owned(); let style_vector = style_vectors.slice(s![style_id as usize, ..]).to_owned();
let diff = (style_vector - &mean) * weight; let diff = (style_vector - &mean) * weight;

View File

@@ -214,6 +214,7 @@ impl TTSModelHolder {
) )
} }
#[allow(clippy::type_complexity)]
pub fn parse_text_neo( pub fn parse_text_neo(
&mut self, &mut self,
text: String, text: String,

View File

@@ -1,2 +1,2 @@
# StyleBertVITS2 wasm # StyleBertVITS2 wasm
refer to https://github.com/tuna2134/sbv2-api refer to https://github.com/neodyland/sbv2-api

View File

@@ -11,6 +11,7 @@
}, },
"keywords": [], "keywords": [],
"author": "tuna2134", "author": "tuna2134",
"contributes": ["neodyland"],
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.4", "@biomejs/biome": "^1.9.4",

View File

@@ -0,0 +1 @@
3.11

View File

@@ -1,5 +1,6 @@
style-bert-vits2 git+https://github.com/neodyland/style-bert-vits2-ref
onnxsim onnxsim
numpy<2 numpy<2
zstandard zstandard
onnxruntime onnxruntime
cmake<4

View File

@@ -2,8 +2,16 @@ FROM rust AS builder
WORKDIR /work WORKDIR /work
COPY . . COPY . .
RUN cargo build -r --bin sbv2_api RUN cargo build -r --bin sbv2_api
FROM gcr.io/distroless/cc-debian12 FROM ubuntu AS upx
WORKDIR /work WORKDIR /work
RUN apt update && apt-get install -y upx binutils
COPY --from=builder /work/target/release/sbv2_api /work/main COPY --from=builder /work/target/release/sbv2_api /work/main
COPY --from=builder /work/target/release/*.so /work COPY --from=builder /work/target/release/*.so /work
RUN upx --best --lzma /work/main
RUN find /work -maxdepth 1 -name "*.so" -exec strip --strip-unneeded {} +
RUN find /work -maxdepth 1 -name "*.so" -exec upx --best --lzma {} +
FROM gcr.io/distroless/cc-debian12
WORKDIR /work
COPY --from=upx /work/main /work/main
COPY --from=upx /work/*.so /work
CMD ["/work/main"] CMD ["/work/main"]

View File

@@ -2,9 +2,16 @@ FROM rust AS builder
WORKDIR /work WORKDIR /work
COPY . . COPY . .
RUN cargo build -r --bin sbv2_api -F cuda,cuda_tf32 RUN cargo build -r --bin sbv2_api -F cuda,cuda_tf32
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 FROM ubuntu AS upx
WORKDIR /work WORKDIR /work
RUN apt update && apt-get install -y upx binutils
COPY --from=builder /work/target/release/sbv2_api /work/main COPY --from=builder /work/target/release/sbv2_api /work/main
COPY --from=builder /work/target/release/*.so /work COPY --from=builder /work/target/release/*.so /work
RUN upx --best --lzma /work/main
RUN find /work -maxdepth 1 -name "*.so" -exec strip --strip-unneeded {} +
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04
WORKDIR /work
COPY --from=upx /work/main /work/main
COPY --from=upx /work/*.so /work
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/work ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/work
CMD ["/work/main"] CMD ["/work/main"]

View File

@@ -1,3 +1,3 @@
docker run -it --rm -p 3000:3000 --name sbv2 \ docker run -it --rm -p 3000:3000 --name sbv2 \
-v ./models:/work/models --env-file .env \ -v ./models:/work/models --env-file .env \
ghcr.io/tuna2134/sbv2-api:cpu ghcr.io/neodyland/sbv2-api:cpu

View File

@@ -1,4 +1,4 @@
docker run -it --rm -p 3000:3000 --name sbv2 \ docker run -it --rm -p 3000:3000 --name sbv2 \
-v ./models:/work/models --env-file .env \ -v ./models:/work/models --env-file .env \
--gpus all \ --gpus all \
ghcr.io/tuna2134/sbv2-api:cuda ghcr.io/neodyland/sbv2-api:cuda