Comments (3)
You can convert model to fp16, but you need to CUDA device. You can use the following command:
djl-convert -o model -f OnnxRuntime -m <MODEL_ID> --optimize O4 --device cuda
see: https://github.com/deepjavalibrary/djl/tree/master/extensions/tokenizers#use-command-line
from djl.
You can convert model to fp16, but you need to CUDA device. You can use the following command:
djl-convert -o model -f OnnxRuntime -m <MODEL_ID> --optimize O4 --device cuda
see: https://github.com/deepjavalibrary/djl/tree/master/extensions/tokenizers#use-command-line
I converted the model to fp16 and encountered an exception while loading fp16 model with CrossEncoderBatchTranslator
Caused by: java.lang.UnsupportedOperationException: type is not supported: FLOAT16
at ai.djl.onnxruntime.engine.OrtUtils.toDataType(OrtUtils.java:101)
at ai.djl.onnxruntime.engine.OrtNDArray.getDataType(OrtNDArray.java:65)
at ai.djl.onnxruntime.engine.OrtNDArray.toByteBuffer(OrtNDArray.java:121)
at ai.djl.pytorch.engine.PtNDManager.from(PtNDManager.java:55)
at ai.djl.pytorch.engine.PtNDManager.from(PtNDManager.java:31)
at ai.djl.ndarray.NDArrayAdapter.getAlternativeArray(NDArrayAdapter.java:1315)
at ai.djl.ndarray.NDArrayAdapter.split(NDArrayAdapter.java:876)
at ai.djl.ndarray.NDArray.split(NDArray.java:3173)
at ai.djl.translate.StackBatchifier.unbatchify(StackBatchifier.java:118)
at ai.djl.huggingface.translator.CrossEncoderBatchTranslator.processOutput(CrossEncoderBatchTranslator.java:60)
at ai.djl.huggingface.translator.CrossEncoderBatchTranslator.processOutput(CrossEncoderBatchTranslator.java:30)
at ai.djl.inference.Predictor.batchPredict(Predictor.java:173)
... 5 more
public static DataType toDataType(OnnxJavaType javaType) {
switch (javaType) {
case FLOAT:
return DataType.FLOAT32;
case DOUBLE:
return DataType.FLOAT64;
case INT8:
return DataType.INT8;
case UINT8:
return DataType.UINT8;
case INT32:
return DataType.INT32;
case INT64:
return DataType.INT64;
case BOOL:
return DataType.BOOLEAN;
case UNKNOWN:
return DataType.UNKNOWN;
case STRING:
return DataType.STRING;
default:
throw new UnsupportedOperationException("type is not supported: " + javaType);
}
}
from djl.
I added FLOAT16 in OrtUtils.toDataType and disabled CrossEncoderBatchTranslator.sigmoid(PyTorchLibrary doesn't support fp16 sigmoid op with cpu), and the problem was solved
public static DataType toDataType(OnnxJavaType javaType) {
switch (javaType) {
case FLOAT:
return DataType.FLOAT32;
case FLOAT16:
return DataType.FLOAT16;
case DOUBLE:
return DataType.FLOAT64;
case INT8:
return DataType.INT8;
case UINT8:
return DataType.UINT8;
case INT32:
return DataType.INT32;
case INT64:
return DataType.INT64;
case BOOL:
return DataType.BOOLEAN;
case UNKNOWN:
return DataType.UNKNOWN;
case STRING:
return DataType.STRING;
default:
throw new UnsupportedOperationException("type is not supported: " + javaType);
}
}
from djl.
Related Issues (20)
- Tokenizer.json compability with jni rust tokenizers - data did not match any variant of untagged enum HOT 2
- Support for FP8 quantization with TensorRT-LLM HOT 2
- 128 dimension face matching algo
- Is there any version of pytorch native library for cudnn9 HOT 2
- Using Llama for inference, some Chinese characters may become garbled
- how to limit OnnxRuntime cpu usage? HOT 1
- 0.27调用tensorflow的pb模型崩溃(可以加载模型,推理时崩溃) HOT 5
- TorchScript inference slower than default torch model HOT 4
- [FATAL] extensions/tokenizers/rust/src/lib.rs crashes the process HOT 1
- CUBLAS_STATUS_NOT_INITIALIZED HOT 10
- UnsatisfiedLinkError: 'boolean ai.djl.pytorch.jni.PyTorchLibrary.torchIsContiguous(long)' HOT 2
- How can I implement the Adaline perceptron in DJL
- pytorch-model-zoo: PtSsdTranslator.Builder.self() returns null
- TextEmbeddingTranslator fails with "EngineException: Expected all tensors to be on the same device"
- tensorrt 的demo 有吗 yolov8的
- resize diff between java djl and python cv2 HOT 1
- Does Lightgbm support multi-class inference? HOT 1
- ONNX Engine Options Bug, ONNX features cannot be defined,It's a parameter type design problem
- [pytorch] UnsatisfiedLinkError on Windows11/Intel HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djl.