Skip to content

Commit

Permalink
--accelerator--deviceに (#399)
Browse files Browse the repository at this point in the history
* `--accelerator` → `--device`

* リネーム漏れを直す

Co-authored-by: Gray Suitcase <[email protected]>

* PowerShell版も対応

* download.mdを更新

---------

Co-authored-by: Gray Suitcase <[email protected]>
  • Loading branch information
qryxip and PickledChair authored Jan 29, 2023
1 parent aa0bbf1 commit 3e7a5cb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/download_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
open_jtalk_dic_utf_8-1.11
- name: DirectML option確認
os: windows-latest
download_command: cargo run -vv -p download -- --accelerator directml
download_command: cargo run -vv -p download -- --device directml
download_dir: voicevox_core
check_items: |
core.dll
Expand All @@ -101,7 +101,7 @@ jobs:
*curand*
- name: DirectMLかつMin option確認
os: windows-latest
download_command: cargo run -vv -p download -- --accelerator directml --min
download_command: cargo run -vv -p download -- --device directml --min
download_dir: voicevox_core
check_items: |
core.dll
Expand All @@ -118,7 +118,7 @@ jobs:
open_jtalk_dic_utf_8-1.11
- name: cuda option確認
os: windows-latest
download_command: cargo run -vv -p download -- --accelerator cuda
download_command: cargo run -vv -p download -- --device cuda
download_dir: voicevox_core
check_items: |
core.dll
Expand All @@ -139,7 +139,7 @@ jobs:
*directml*
- name: cudaかつmin option確認
os: windows-latest
download_command: cargo run -vv -p download -- --accelerator cuda --min
download_command: cargo run -vv -p download -- --device cuda --min
download_dir: voicevox_core
check_items: |
core.dll
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
open_jtalk_dic_utf_8-1.11
- name: cuda option確認
os: ubuntu-latest
download_command: ./scripts/downloads/download.sh --accelerator cuda
download_command: ./scripts/downloads/download.sh --device cuda
download_dir: voicevox_core
check_items: |
libcore.so
Expand All @@ -248,7 +248,7 @@ jobs:
*directml*
- name: cudaかつmin option確認
os: ubuntu-latest
download_command: ./scripts/downloads/download.sh --accelerator cuda --min
download_command: ./scripts/downloads/download.sh --device cuda --min
download_dir: voicevox_core
check_items: |
libcore.so
Expand Down
32 changes: 16 additions & 16 deletions crates/download/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ struct Args {
#[arg(long, default_value("latest"))]
additional_libraries_version: String,

/// ダウンロードするacceleratorを指定する(cudaはlinuxのみ)
#[arg(value_enum, long, default_value(<&str>::from(Accelerator::default())))]
accelerator: Accelerator,
/// ダウンロードするデバイスを指定する(cudaはlinuxのみ)
#[arg(value_enum, long, default_value(<&str>::from(Device::default())))]
device: Device,

/// ダウンロードするcpuのアーキテクチャを指定する
#[arg(value_enum, long, default_value(CpuArch::default_opt().map(<&str>::from)))]
Expand All @@ -79,7 +79,7 @@ struct Args {

#[derive(Default, ValueEnum, Display, IntoStaticStr, Clone, Copy, PartialEq)]
#[strum(serialize_all = "kebab-case")]
enum Accelerator {
enum Device {
#[default]
Cpu,
Cuda,
Expand Down Expand Up @@ -132,34 +132,34 @@ async fn main() -> anyhow::Result<()> {
output,
version,
additional_libraries_version,
accelerator,
device,
cpu_arch,
os,
} = Args::parse();

let octocrab = &octocrab()?;

let core = find_gh_asset(octocrab, CORE_REPO_NAME, &version, |tag| {
let accelerator = match (os, accelerator) {
(Os::Linux, Accelerator::Cuda) => "gpu",
(_, accelerator) => accelerator.into(),
let device = match (os, device) {
(Os::Linux, Device::Cuda) => "gpu",
(_, device) => device.into(),
};
format!("{CORE_REPO_NAME}-{os}-{cpu_arch}-{accelerator}-{tag}.zip")
format!("{CORE_REPO_NAME}-{os}-{cpu_arch}-{device}-{tag}.zip")
})
.await?;

let additional_libraries = OptionFuture::from((accelerator != Accelerator::Cpu).then(|| {
let additional_libraries = OptionFuture::from((device != Device::Cpu).then(|| {
find_gh_asset(
octocrab,
ADDITIONAL_LIBRARIES_REPO_NAME,
&additional_libraries_version,
|_| {
let accelerator = match accelerator {
Accelerator::Cpu => unreachable!(),
Accelerator::Cuda => "CUDA",
Accelerator::Directml => "DirectML",
let device = match device {
Device::Cpu => unreachable!(),
Device::Cuda => "CUDA",
Device::Directml => "DirectML",
};
format!("{accelerator}-{os}-{cpu_arch}.zip")
format!("{device}-{os}-{cpu_arch}.zip")
},
)
}))
Expand All @@ -168,7 +168,7 @@ async fn main() -> anyhow::Result<()> {

info!("対象OS: {os}");
info!("対象CPUアーキテクチャ: {cpu_arch}");
info!("ダウンロードアーティファクトタイプ: {accelerator}");
info!("ダウンロードデバイスタイプ: {device}");
info!("ダウンロード{CORE_REPO_NAME}バージョン: {}", core.tag);
if let Some(GhAsset { tag, .. }) = &additional_libraries {
info!("ダウンロード追加ライブラリバージョン: {tag}");
Expand Down
6 changes: 3 additions & 3 deletions docs/downloads/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ curl -sSfL https://github.com/VOICEVOX/voicevox_core/releases/latest/download/do

```PowerShell
Invoke-WebRequest https://github.com/VOICEVOX/voicevox_core/releases/latest/download/download.ps1 -OutFile ./download.ps1
./download.ps1 -Accelerator directml
./download.ps1 -Device directml
```

<a id="cuda"></a>
Expand All @@ -37,13 +37,13 @@ Invoke-WebRequest https://github.com/VOICEVOX/voicevox_core/releases/latest/down

```PowerShell
Invoke-WebRequest https://github.com/VOICEVOX/voicevox_core/releases/latest/download/download.ps1 -OutFile ./download.ps1
./download.ps1 -Accelerator cuda
./download.ps1 -Device cuda
```

### Linux の場合

```bash
curl -sSfL https://github.com/VOICEVOX/voicevox_core/releases/latest/download/download.sh | bash -s -- --accelerator cuda
curl -sSfL https://github.com/VOICEVOX/voicevox_core/releases/latest/download/download.sh | bash -s -- --device cuda
```

<a id="help"></a>
Expand Down
28 changes: 14 additions & 14 deletions scripts/downloads/download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Param(
[Parameter()]
[ValidateSet("cpu","cuda","directml")]
[string]
# ダウンロードするAcceleratorを指定する(cpu,cuda,directmlを指定可能)
$Accelerator = "cpu",
# ダウンロードするデバイスを指定する(cpu,cuda,directmlを指定可能)
$Device = "cpu",
[Parameter()]
[bool]
# ダウンロードするライブラリを最小限にするように指定
Expand All @@ -46,18 +46,18 @@ $VoicevoxAdditionalLibrariesBaseUrl="https://github.com/VOICEVOX/voicevox_additi
$OpenJtalkDictUrl="https://jaist.dl.sourceforge.net/project/open-jtalk/Dictionary/open_jtalk_dic-1.11/open_jtalk_dic_utf_8-1.11.tar.gz"
$OpenJtalkDictDirName="open_jtalk_dic_utf_8-1.11"

Function Voicevox-Core-Releases-Url($Os,$CpuArch,$Accelerator,$Version){
"${VoicevoxCoreRepositoryBaseUrl}/releases/download/${Version}/voicevox_core-${Os}-${CpuArch}-${Accelerator}-${Version}.zip"
Function Voicevox-Core-Releases-Url($Os,$CpuArch,$Device,$Version){
"${VoicevoxCoreRepositoryBaseUrl}/releases/download/${Version}/voicevox_core-${Os}-${CpuArch}-${Device}-${Version}.zip"
}

Function Voicevox-Additional-Libraries-Releases-Url($Os,$CpuArch,$Accelerator,$Version){
If ( $Accelerator -eq "cuda" ){
$Accelerator="CUDA"
} ElseIf ( $Accelerator -eq "directml" ){
$Accelerator="DirectML"
Function Voicevox-Additional-Libraries-Releases-Url($Os,$CpuArch,$Device,$Version){
If ( $Device -eq "cuda" ){
$Device="CUDA"
} ElseIf ( $Device -eq "directml" ){
$Device="DirectML"
}

"${VoicevoxAdditionalLibrariesBaseUrl}/releases/download/${Version}/${Accelerator}-${Os}-${CpuArch}.zip"
"${VoicevoxAdditionalLibrariesBaseUrl}/releases/download/${Version}/${Device}-${Os}-${CpuArch}.zip"
}

Function Latest-Version($BaseUrl){
Expand Down Expand Up @@ -123,7 +123,7 @@ If ( [string]::IsNullOrEmpty($CpuArch) ){
$CpuArch=Target-Arch
}

If ( $Accelerator -eq "cpu" ){
If ( $Device -eq "cpu" ){
$AdditionalLibrariesVersion=""
}

Expand All @@ -138,11 +138,11 @@ If ( $AdditionalLibrariesVersion -eq "latest" ){
echo "対象OS:$Os"
echo "対象CPUアーキテクチャ:$cpu_arch"
echo "ダウンロードvoicevox_coreバージョン:$version"
echo "ダウンロードアーティファクトタイプ:$Accelerator"
echo "ダウンロードアーティファクトタイプ:$Device"
echo "出力先:$Output"

$VoicevoxCoreUrl=Voicevox-Core-Releases-Url "$Os" "$CpuArch" "$Accelerator" "$Version"
$VoicevoxAdditionalLibrariesUrl=Voicevox-Additional-Libraries-Releases-Url "$Os" "$CpuArch" "$Accelerator" "$AdditionalLibrariesVersion"
$VoicevoxCoreUrl=Voicevox-Core-Releases-Url "$Os" "$CpuArch" "$Device" "$Version"
$VoicevoxAdditionalLibrariesUrl=Voicevox-Additional-Libraries-Releases-Url "$Os" "$CpuArch" "$Device" "$AdditionalLibrariesVersion"

Download-and-Extract "voicevox_core" "$VoicevoxCoreUrl" "$Output"

Expand Down
40 changes: 20 additions & 20 deletions scripts/downloads/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ help(){
-o|--output \$directory 出力先の指定(default ./voicevox_core)
-v|--version \$version ダウンロードするvoicevox_coreのバージョンの指定(default latest)
--additional-libraries-version \$version 追加でダウンロードするライブラリのバージョン
--accelerator \$accelerator ダウンロードするacceleratorを指定する(cpu,cudaを指定可能.cudaはlinuxのみ)
--device \$device ダウンロードするデバイスを指定する(cpu,cudaを指定可能.cudaはlinuxのみ)
--cpu-arch \$cpu_arch ダウンロードするcpuのアーキテクチャを指定する
--min ダウンロードするライブラリを最小限にするように指定
--os ダウンロードする対象のOSを指定する
Expand All @@ -23,27 +23,27 @@ open_jtalk_dict_dir_name="open_jtalk_dic_utf_8-1.11"
voicevox_core_releases_url(){
os=$1
cpu_arch=$2
accelerator=$3
device=$3
version=$4

if [ "$os" = "linux" ] && [ "$accelerator" = "cuda" ];then
accelerator="gpu"
if [ "$os" = "linux" ] && [ "$device" = "cuda" ];then
device="gpu"
fi
url="$voicevox_core_repository_base_url/releases/download/$version/voicevox_core-$os-$cpu_arch-$accelerator-$version.zip"
url="$voicevox_core_repository_base_url/releases/download/$version/voicevox_core-$os-$cpu_arch-$device-$version.zip"
echo "$url"
}

voicevox_additional_libraries_url(){
os=$1
cpu_arch=$2
accelerator=$3
device=$3
version=$4
if [ "$accelerator" = "cuda" ];then
accelerator="CUDA"
elif [ "$accelerator" = "directml" ];then
accelerator="DirectML"
if [ "$device" = "cuda" ];then
device="CUDA"
elif [ "$device" = "directml" ];then
device="DirectML"
fi
url="${voicevox_additional_libraries_base_url}/releases/download/${version}/${accelerator}-${os}-${cpu_arch}.zip"
url="${voicevox_additional_libraries_base_url}/releases/download/${version}/${device}-${os}-${cpu_arch}.zip"
echo "$url"
}

Expand Down Expand Up @@ -116,7 +116,7 @@ os=""
cpu_arch=""
version="latest"
additional_libraries_version="latest"
accelerator=""
device=""
output="./voicevox_core"
min=""

Expand All @@ -136,8 +136,8 @@ do
--additional-libraries-version)
additional_libraries_version="$2"
shift;;
--accelerator)
accelerator="$2"
--device)
device="$2"
shift;;
--cpu-arch)
cpu_arch="$2"
Expand Down Expand Up @@ -165,11 +165,11 @@ if [ -z "$cpu_arch" ];then
cpu_arch=$(target_arch)
fi

if [ "$accelerator" = "" ];then
accelerator="cpu"
if [ "$device" = "" ];then
device="cpu"
fi

if [ "$accelerator" = "cpu" ];then
if [ "$device" = "cpu" ];then
additional_libraries_version=""
fi

Expand All @@ -185,15 +185,15 @@ fi
echo "対象OS:$os"
echo "対象CPUアーキテクチャ:$cpu_arch"
echo "ダウンロードvoicevox_coreバージョン:$version"
echo "ダウンロードアーティファクトタイプ:$accelerator"
echo "ダウンロードデバイスタイプ:$device"

if [ "$additional_libraries_version" != "" ];then
echo "ダウンロード追加ライブラリバージョン:$additional_libraries_version"
fi


voicevox_core_url=$(voicevox_core_releases_url "$os" "$cpu_arch" "$accelerator" "$version")
voicevox_additional_libraries_url=$(voicevox_additional_libraries_url "$os" "$cpu_arch" "$accelerator" "$additional_libraries_version")
voicevox_core_url=$(voicevox_core_releases_url "$os" "$cpu_arch" "$device" "$version")
voicevox_additional_libraries_url=$(voicevox_additional_libraries_url "$os" "$cpu_arch" "$device" "$additional_libraries_version")

download_and_extract "voicevox_core" "$voicevox_core_url" "$output" &
voicevox_core_download_task=$!
Expand Down

0 comments on commit 3e7a5cb

Please sign in to comment.