I'm trying to test a tflite model that I created in a JupyterNotebooks file. I'm running Python 3.7, and after importing tflite with line:
import tflite_runtime.interpreter as tflite
and then calling an instance of the interpreter with:
interpreter = tflite.Interpreter(model_path=modelPath)
(Note the model path is pointing at a .tflite file that I exported). The kernel dies.
Thanks for help
Jack
Related
I am trying to install and configure Globus Connect Personal for Linux (i have a CentOS 8), following this tutorial. However, when I try to set up Globus connect personal by running ./globusconnectpersonal -start i get this error
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'gc.py'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = ''
sys.base_prefix = '/tmp/build/80754af9/python_1599203911753/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho'
sys.base_exec_prefix = '/tmp/build/80754af9/python_1599203911753/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho'
sys.executable = ''
sys.prefix = '/tmp/build/80754af9/python_1599203911753/_h_env_placehold_
Subprocess pid 1722896 exited, rc=1
Traceback (most recent call last):
File "./gc-ctrl.py", line 369, in <module>
start(debug=False)
File "./gc-ctrl.py", line 191, in start
send2clients(fds[2:], mesg.encode('utf-8'))
AttributeError: 'bytes' object has no attribute 'encode'
does anybody know what this could mean?
I think there needs to be PYTHONHOME and PYTHONPATH. I created a conda environment with just the correct version of python in it. Then I ran ./globusconnectpersonal inside the conda environment.
Using a conda environment also works for the non-GUI form of globus.
I have not tried setting the paths manually.
I ran into the same problem when I was using Python3.8 in a Miniconda environment. When I disabled conda with:
conda deactivate
Then I could run "globusconnectpersonal -start" with my native Python2.7. I don't know if it was because the client needed Python2 or if conda was interfering, but his resolved the problem for me.
I have a java file that I would normally execute by doing
java -jar jarname.jar arguments
I want to be able to run this file from R in the most system agnostic way possible. My current pipeline partially relies on rJava do identify JAVA_HOME and run the jar by doing
# path for the example file below
pathToJar = 'pdftk-java.jar'
# start up java session
rJava::.jinit()
# find JAVA_HOME
javaPath = rJava::.jcall( 'java/lang/System', 'S', 'getProperty', 'java.home' )
# get all java files
javaFiles = list.files(javaPath,recursive = TRUE,full.names = TRUE)
# find java command
java = javaFiles[grepl('/java($|\\.exe)',javaFiles)]
# run the jar using system
system(glue::glue('{shQuote(java)} -jar {shQuote(pathToJar)} arguments'))
This does work fine but I was wondering if there was a reliable way to replicate execution of a jar through rJava itself. I want to do this because
I want to avoid any possible system dependent issues when finding the java command from JAVA_HOME
I already started an rJava session just to get the JAVA_HOME. I might as well use it since .jinit isn't undoable
I not that familiar with what calling a jar through -jar does and I am curious. Can it be done in a jar independent way? If not what should I look for in the code to know how to do this.
This is the file in I am working with. Taken from https://gitlab.com/pdftk-java/pdftk/tree/master
Executing JAR file is (essentially) running class file that is embedded inside JAR.
Instead of calling system and executing it as external application, you can do following:
make sure to add your JAR file to CLASSPATH
rJava::.jaddClassPath(pathToJar)
check inside JAR file what is the main class. Look into META-INF/MANIFEST.MF file to identify the main class. (In this case com.gitlab.pdftk_java.pdftk)
instantiate class inside R.
newObj = rJava::.jnew('com/gitlab/pdftk_java/pdftk')
run the class following way: http://www.owsiak.org/running-java-code-in-r/
Update
Running JAR file (calling main method of Main-class) is the same things as calling any other method inside Java based class. Please note that main method takes array of Strings as argument. Take a look here for sample: http://www.owsiak.org/running-jar-file-from-r-using-rjava-without-spawning-new-process/
newObj$main(rJava::.jarray('--version'))
For this specific case if you look at the source code for this class, you'll see that it terminates the session
public static void main(String[] args) {
System.exit(main_noexit(args));
}
This will also terminate your R session. Since all main function does it to call main_noexit then exit, you can replace main with main_noexit in the code above.
newObj$main_noexit(rJava::.jarray('--version'))
I'd like to create a self-contained Jupyter notebook that uses h2o to import and model data that resides in a relational database. The docs show an example where h2o is launched with the JDBC driver in the classpath, e.g.
java -cp <path_to_h2o_jar>:<path_to_jdbc_driver_jar> water.H2OApp
I'd prefer to start h2o from a notebook that's a standalone, reproducible artifact rather than have special steps to prep the environment prior to running the notebook. If I run the following snippet:
import h2o
h2o.init()
connection_url = "jdbc:mysql://mysql.woolford.io/mydb"
select_query = "SELECT description, price FROM mytable"
username = "myuser"
password = "b#dp#ss"
mytable_data = h2o.import_sql_select(connection_url, select_query, username, password)
... the import_sql_select method fails because the driver isn't loaded:
Server error java.lang.RuntimeException:
Error: SQLException: No suitable driver found for jdbc:mysql://mysql.woolford.io/mydb
Is there a way to load the driver when the h2o.init() call is made? Or a best practice for this?
h2o.init() takes a parameter called extra_classpath. You can use this parameter to provide the path to the JDBC driver and H2O will launch with the driver.
This option is designed exactly for the purpose of not having to start H2O outside of the notebook interface.
Example:
import h2o
h2o.init(extra_classpath=["/Users/michal/Downloads/apache-hive-2.2.0-bin/jdbc/hive-jdbc-2.2.0-standalone.jar"])
I am running exist-db on windows and would like to execute an external windows program.
This works inside the normal windows shell:
C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90
And I would like to execute the same program from my xquery script (I have uploaded all the needed files according to my specified paths to my exist-db):
xquery version '3.1';
import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";
declare variable $options := '<options>
<workingDir>/db/apps/test-project/images</workingDir>
<stdin><line>/db/apps/execute-test/images/image1.rti -q 90</line></stdin>
</options>';
(:process:execute($webRtiMaker, <options/>):)
process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', $options)
Even if I only execute the program without parameters (if I execute it inside windows I get the parameters as overview inside the command prompt so I should also receive some kind of output):
process:execute('/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe', <options/>)
But I get the error:
exerr:ERROR An IO error occurred while executing the process /db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe: Cannot run program "/db/apps/execute-test/resources/RTIMaker/webGLRtiMaker.exe": CreateProcess error=2, The System cannot find the file ...
I used this as reference: Execute External Process
What am I doing wrong?
I have not tried this recently, but try the following:
import module namespace process="http://exist-db.org/xquery/process" at "java:org.exist.xquery.modules.process.ProcessModule";
let $cmd := 'C:\path\to\webGLRtiMaker.exe C:\path\to\ImageFile.rti -q 90'
return
<results>{process:execute($cmd, <options/>)}</results>
There is an article at the XQuery WikiBook about it.
Unfortunately it is not possible to start an executable that is stored inside the database. The java API requires direct access to a file on the filesystem, and the '/db/....' path is not.
I wanted to run this example script: http://mazamascience.com/WorkingWithData/?p=912 from Windows command line. So I opened the command line and typed Rscript tryCatch.R 1. However, I keep getting the error message Error: R not found. I did set the PATH environment variable as C:\Programme\R\R-3.0.1\bin. If I just type R.exe, it does start R, but it cannot find the packages that are to be loaded at start (e.g. package 'utils' in options<"defaultPackages"> was not found). I guess I have to set another path to the libraries somewhere, but I haven't got any idea where to do this.
UPDATE: After explicitly typing PATH C:\Programme\R\R-3.0.1\bin (rather than just adding this to the value of the environment variable PATH) it seems that R is found. However, a new problem occurs: In normalizePath<path.expand(path), winslash, mustWork>: path[2] = "C:/Programme/R/R-3.0.1/library": Access denied, the same than for the methods library. Then: Calls: .First ... library -> .getRequiredPackages2 -> library -> normalizePath Execution stopped. I'm using Windows 7 and I do have administrator rights.
Rscript is very handy (R CMD BATCH is the old way to ) specially under windows, But generally under I create a batch file to avoid all path's headache.
For example say launcher.bat:
#echo off
C:
PATH C:\Programme\R\R-3.0.1\bin;%path%
cd PATH_TO_YOUR_RSCRIPT
Rscript tryCatch.R 1
pause
And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using shell:
shell('path_to_launcher\launcher.bat')
I've found out that it was a language-specific problem on Windows 7, similar to what is described here: https://stat.ethz.ch/pipermail/r-help/2011-May/276932.html
After changing PATH to C:\Program Files\R\R-3.0.1\bin the script is properly executed from the command prompt.
Thanks to everyone who tried to help!
I ran into this problem under windows 7, apparently, when setting environment variables>user variables the path is not added into the PATH, so the user must add this path in system variables > PATH
at the end just add the path to your .EXE files and voila.