Skip to content

Commit 34bb9d8

Browse files
authored
Allow uncompressed conda execution enviroments (triton-inference-server#266)
Allow uncompressed conda execution environments and add documentation for custom execution environments.
1 parent 34cc89f commit 34bb9d8

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ any C++ code.
4545
- [`initialize`](#initialize)
4646
- [`execute`](#execute)
4747
- [Default Mode](#default-mode)
48-
- [Error Handling](#error-handling)
48+
- [Error Handling](#error-handling)
4949
- [Decoupled mode](#decoupled-mode)
5050
- [Use Cases](#use-cases)
5151
- [Known Issues](#known-issues)
@@ -62,8 +62,8 @@ any C++ code.
6262
- [Running Multiple Instances of Triton Server](#running-multiple-instances-of-triton-server)
6363
- [Business Logic Scripting](#business-logic-scripting)
6464
- [Using BLS with Decoupled Models](#using-bls-with-decoupled-models)
65-
- [Using BLS with Stateful Models](#using-bls-with-stateful-models)
6665
- [Model Loading API](#model-loading-api)
66+
- [Using BLS with Stateful Models](#using-bls-with-stateful-models)
6767
- [Limitation](#limitation)
6868
- [Interoperability and GPU Support](#interoperability-and-gpu-support)
6969
- [`pb_utils.Tensor.to_dlpack() -> PyCapsule`](#pb_utilstensorto_dlpack---pycapsule)
@@ -72,7 +72,9 @@ any C++ code.
7272
- [Input Tensor Device Placement](#input-tensor-device-placement)
7373
- [Frameworks](#frameworks)
7474
- [PyTorch](#pytorch)
75+
- [PyTorch Determinism](#pytorch-determinism)
7576
- [TensorFlow](#tensorflow)
77+
- [TensorFlow Determinism](#tensorflow-determinism)
7678
- [Custom Metrics](#custom-metrics)
7779
- [Examples](#examples)
7880
- [AddSub in NumPy](#addsub-in-numpy)
@@ -81,7 +83,8 @@ any C++ code.
8183
- [Business Logic Scripting](#business-logic-scripting-1)
8284
- [Preprocessing](#preprocessing)
8385
- [Decoupled Models](#decoupled-models)
84-
- [Auto-complete Config](#auto-complete-config)
86+
- [Model Instance Kind](#model-instance-kind)
87+
- [Auto-complete config](#auto-complete-config)
8588
- [Custom Metrics](#custom-metrics-1)
8689
- [Running with Inferentia](#running-with-inferentia)
8790
- [Logging](#logging)
@@ -678,7 +681,7 @@ above.
678681
If you want to create a tar file that contains all your Python dependencies or
679682
you want to use different Python environments for each Python model you need to
680683
create a *Custom Execution Environment* in Python backend.
681-
Currently, Python backend only supports
684+
Currently, Python backend supports
682685
[conda-pack](https://conda.github.io/conda-pack/) for this purpose.
683686
[conda-pack](https://conda.github.io/conda-pack/) ensures that your conda
684687
environment is portable. You can create a tar file for your conda environment
@@ -704,7 +707,17 @@ If this variable is not exported and similar packages are installed outside your
704707
conda environment, your tar file may not contain all the dependencies required
705708
for an isolated Python environment.
706709

707-
After creating the tar file from the conda environment, you need to tell Python
710+
Alternatively, Python backend also supports unpacked conda execution
711+
environments, given it points to an activation script to setup the conda
712+
environment. To do this, the execution environment can be first packed using
713+
[conda-pack](https://conda.github.io/conda-pack/) and then unpacked, or created
714+
using [conda create -p](https://docs.conda.io/projects/conda/en/latest/commands/create.html).
715+
In this case, the conda activation script is located in:
716+
```$path_to_conda_pack/lib/python<your.python.version>/site-packages/conda_pack/scripts/posix/activate```
717+
This speeds up the server loading time for models.
718+
719+
After creating the packed file from the conda environment or creating a conda
720+
environment with a custom activation script, you need to tell Python
708721
backend to use that environment for your model. You can do this by adding the
709722
lines below to the `config.pbtxt` file:
710723

src/pb_env.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <archive.h>
3030
#include <archive_entry.h>
3131
#include <fts.h>
32+
#include <sys/stat.h>
3233

3334
#include <cstdlib>
3435
#include <cstring>
@@ -253,6 +254,21 @@ EnvironmentManager::ExtractIfNotExtracted(std::string env_path)
253254

254255
bool env_extracted = false;
255256
bool re_extraction = false;
257+
258+
// If the path is not a conda-packed file, then bypass the extraction process
259+
struct stat info;
260+
if (stat(canonical_env_path, &info) != 0) {
261+
throw PythonBackendException(
262+
std::string("stat() of : ") + canonical_env_path + " returned error.");
263+
} else if (S_ISDIR(info.st_mode)) {
264+
LOG_MESSAGE(
265+
TRITONSERVER_LOG_VERBOSE,
266+
(std::string("Returning canonical path since EXECUTION_ENV_PATH does "
267+
"not contain compressed path. Path: ") +
268+
canonical_env_path)
269+
.c_str());
270+
return canonical_env_path;
271+
}
256272
const auto env_itr = env_map_.find(canonical_env_path);
257273
if (env_itr != env_map_.end()) {
258274
// Check if the environment has been modified and would

0 commit comments

Comments
 (0)