Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa4a24b

Browse files
authored
Multi-cuda and venv (#604)
1 parent67de8e9 commitaa4a24b

File tree

11 files changed

+343
-173
lines changed

11 files changed

+343
-173
lines changed

‎pgml-extension/.editrconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
[*]
3+
end_of_line = lf
4+
insert_final_newline = true
5+
6+
[*.py]
7+
indent_size = 4
8+
indent_style = space

‎pgml-extension/requirements.txt‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
accelerate==0.16.0
2+
datasets==2.10.1
3+
deepspeed==0.8.1
4+
lightgbm
5+
pandas==1.5.3
6+
rich==13.3.1
7+
rouge
8+
sacrebleu
9+
scikit-learn
10+
sentencepiece
11+
sentence-transformers==2.2.2
12+
torch==1.13.1
13+
torchaudio==0.13.1
14+
torchvision==0.14.1
15+
tqdm==4.64.1
16+
transformers==4.26.1
17+
xgboost
18+
InstructorEmbedding
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE OR REPLACEFUNCTIONpgml.activate_venv(venvtext)
2+
RETURNSboolean
3+
LANGUAGE c
4+
STRICT
5+
AS'$libdir/pgml', $function$activate_venv_wrapper$function$;

‎pgml-extension/src/api.rs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ use serde_json::json;
1414
usecrate::bindings::sklearn::package_version;
1515
usecrate::orm::*;
1616

17+
#[cfg(feature ="python")]
18+
#[pg_extern]
19+
pubfnactivate_venv(venv:&str) ->bool{
20+
crate::bindings::venv::activate_venv(venv)
21+
}
22+
1723
#[cfg(feature ="python")]
1824
#[pg_extern]
1925
pubfnvalidate_python_dependencies() ->bool{
26+
crate::bindings::venv::activate();
27+
2028
Python::with_gil(|py|{
2129
let sys =PyModule::import(py,"sys").unwrap();
2230
let version:String = sys.getattr("version").unwrap().extract().unwrap();
@@ -51,6 +59,7 @@ pub fn validate_python_dependencies() {}
5159
#[cfg(feature ="python")]
5260
#[pg_extern]
5361
pubfnpython_package_version(name:&str) ->String{
62+
crate::bindings::venv::activate();
5463
package_version(name)
5564
}
5665

@@ -79,6 +88,7 @@ pub fn validate_shared_library() {
7988
#[cfg(feature ="python")]
8089
#[pg_extern]
8190
fnpython_version() ->String{
91+
crate::bindings::venv::activate();
8292
letmut version =String::new();
8393

8494
Python::with_gil(|py|{
@@ -564,10 +574,10 @@ pub fn transform_json(
564574
task:JsonB,
565575
args:default!(JsonB,"'{}'"),
566576
inputs:default!(Vec<String>,"ARRAY[]::TEXT[]"),
567-
cache:default!(bool,false)
577+
cache:default!(bool,false),
568578
) ->JsonB{
569579
JsonB(crate::bindings::transformers::transform(
570-
&task.0,&args.0,&inputs, cache
580+
&task.0,&args.0,&inputs, cache,
571581
))
572582
}
573583

@@ -577,13 +587,13 @@ pub fn transform_string(
577587
task:String,
578588
args:default!(JsonB,"'{}'"),
579589
inputs:default!(Vec<String>,"ARRAY[]::TEXT[]"),
580-
cache:default!(bool,false)
590+
cache:default!(bool,false),
581591
) ->JsonB{
582592
letmut task_map =HashMap::new();
583593
task_map.insert("task", task);
584594
let task_json =json!(task_map);
585595
JsonB(crate::bindings::transformers::transform(
586-
&task_json,&args.0,&inputs, cache
596+
&task_json,&args.0,&inputs, cache,
587597
))
588598
}
589599

‎pgml-extension/src/bindings/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub mod linfa;
1111
pubmod sklearn;
1212
#[cfg(feature ="python")]
1313
pubmod transformers;
14+
#[cfg(feature ="python")]
15+
pubmod venv;
1416
pubmod xgboost;
1517

1618
pubtypeFit =fn(dataset:&Dataset,hyperparams:&Hyperparams) ->Box<dynBindings>;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp