Comments (6)
@aizhimin thanks for posting! Can you post the script so I can look? Python version would help as well.
from deeplearning4j.
@agibsonccc Python version is 3.10.2
the script is like this :
`
xml_data_str = xml_data_bytes.decode(encoding='utf-8')
root = etree.fromstring(xml_data_str)
lotRunJson =generate_lotrunjson(root)
machineRcpJson =generate_machinercpjson(root)
imageJson =generate_imagejson(root, lotRunJson)
waferRunJson =generate_waferrunjson(root)
targetJson =generate_targetjson(root, lotRunJson)
measurementJson =generate_measurementjson(root)
measurementResultJson =generate_measurementresultjson(root)
`
this script takes only 0.00718 seconds to execute through Python. But it takes 17 seconds to execute through Python4J.
Is it slower to pass the binary data of a file as input in Java? Do I need to pass the file path in and let Python read the file?
from deeplearning4j.
@aizhimin can you give me something I can run standalone? If I'm going to benchmark something you and I need a common baseline to work with.
from deeplearning4j.
@agibsonccc Sorry, my file is confidential. My question is that the code for xml parsing executed directly in the python environment runs very fast. However, the xml parsing executed through python4j calls is very slow. Is this due to the need to load the python parser? Or is it because the input parameters cannot pass file data streams?
from deeplearning4j.
@aizhimin I don't care about your secrets. A vague description I can't directly run isn't something I'm inclined to spend time on. I believe you but you putting up barriers to me reproducing the issue isn't going to help get this fixed. Meet me half way and setup a trivial example you can show me and I'll be more likely to take a look at this when I get time. The goal is to have a common "language" we can speak here (in this case code) that allows us both to run the same environment and baseline so we can both agree the issue is resolved.
from deeplearning4j.
The python script like this:
from lxml import etree
def dumps_json(obj):
if obj:
return json.dumps(obj)
return json.dumps("")
xml_data = xml_data_bytes.decode(encoding='utf-8')
root = etree.fromstring(xml_data)
result = {}
for child in root:
result[child.tag] = child.text
resultJson = dumps_json(result)
The java code like this:
try(PythonGIL gil = PythonGIL.lock()){
try(PythonGC gc = PythonGC.watch()){
List<PythonVariable> inputs = new ArrayList<>();
byte[] xml_data_bytes = FileUtils.readFileToByteArray(new File("/Users/aizhimin/Documents/test.xml"));
inputs.add(new PythonVariable<>("xml_data_bytes", PythonTypes.BYTES, xml_data_bytes));
List<PythonVariable> outputs = new ArrayList<>();
outputs.add(new PythonVariable<>("resultJson", PythonTypes.STR));
String code = FileUtils.readFileToString(new File("/Users/aizhimin/Documents/testxml.py"));
long startTime = System.currentTimeMillis();
PythonExecutioner.exec(code, inputs, outputs);
long endTime = System.currentTimeMillis();
System.out.println("Cost time:" + (endTime - startTime) / 1000.0);
for(PythonVariable out : outputs){
System.out.println(out.getName()+":"+out.getValue());
}
}
}catch (Throwable e){
e.printStackTrace();
}
Java takes 2.193s
If only python οΌit takes only 0.0119s
from deeplearning4j.
Related Issues (20)
- Init pretrained models HTTP status code 403 HOT 3
- Please ensure that you have an nd4j backend on your classpath. Please see: https://deeplearning4j.konduit.ai/nd4j/backend HOT 2
- Please update the version of opencsv you are using
- module-info.java for 'modelimport' contains invalid (old) exports HOT 4
- python4j spring boot jar PythonExecutioner init error HOT 3
- Ensure read into byte array from InputStream happens fully HOT 2
- libnd4j: Execution javacpp-cppbuild-compile of goal org.bytedeco:javacpp:1.5.9:build failed: Process exited with an error: 127
- Unable to start UI server
- Unable to use RemoteUIStatsStorageRouter HOT 2
- libnd4j - undefined reference to `sd::PrintTo(sd::NDArray const&, std::ostream*) HOT 1
- Running a a basic CNN training fails on Google Colab!
- AMD GPUs not supported? HOT 4
- Normalized Autoencoder (NAE): Improve outlier detection performance
- Op [multiply] execution failed HOT 1
- error when compiling (exception in thread "main" java.lang.ExceptionInInitializerError) HOT 3
- ND4J: Add an option to only include backends for specified operating systems HOT 5
- WordVectorSerializer should add load Supplier<InputStream> functions HOT 2
- version bug for commons-io?
- [ND4J][CUDA 12] Support nd4j for cuda 12.4.1 ? 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 deeplearning4j.