GithubHelp home page GithubHelp logo

Comments (5)

andrewferlitsch avatar andrewferlitsch commented on May 25, 2024

@dizcology please take a look

from cloudml-samples.

gogasca avatar gogasca commented on May 25, 2024

@Mustufain is this a model in our samples? Take a look at: https://stackoverflow.com/questions/49172710/what-does-google-cloud-ml-engine-do-when-a-json-request-contains-bytes-or-b6 if not a model please open issue in StackOverflow for visibility of the community

from cloudml-samples.

Grandmother avatar Grandmother commented on May 25, 2024

I've met the same problem and found out that ml_engine/local_utils.py uses python to run ml_engine/local_predict.pyc that is built for python2.7.
My python is python3, so when ml_engine/local_utils.py tries to run ml_engine/local_predict.pyc using python (actually python3), it fails with error:

RuntimeError: Bad magic number in .pyc file

Solution 1:

You can just make python2 as default one in system.

Solution 2:

I changed ml_engine/local_utils.py with such patch:

83c83
<   python_executables = files.SearchForExecutableOnPath("python")
---
>   python_executables = files.SearchForExecutableOnPath("python2")
114a115
>   log.debug(args)
124,126c125,130
<   for instance in instances:
<     proc.stdin.write((json.dumps(instance) + "\n").encode("utf-8"))
<   proc.stdin.flush()
---
>   try:
>     for instance in instances:
>       proc.stdin.write((json.dumps(instance) + "\n").encode("utf-8"))
>     proc.stdin.flush()
>   except:
>     pass

* log.degub(args) needed to see what we are running.
** try-catch needed to make script able to read and print an error ocurred while running ml_engine/local_predict.pyc.

from cloudml-samples.

Grandmother avatar Grandmother commented on May 25, 2024

Here is a patch in unified format:

--- /usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/ml_engine/local_utils_orig.py      2020-05-14 10:18:40.389442573 +0300
+++ /usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/ml_engine/local_utils.py   2020-05-14 12:28:41.053351849 +0300
@@ -80,7 +80,7 @@
     encoding.SetEncodedValue(env, "CLOUDSDK_ROOT", sdk_root)
     # We want to use whatever the user's Python was, before the Cloud SDK started
     # changing the PATH. That's where Tensorflow is installed.
-    python_executables = files.SearchForExecutableOnPath("python")
+    python_executables = files.SearchForExecutableOnPath("python2")
     # Need to ensure that ml_sdk is in PYTHONPATH for the import in
     # local_predict to succeed.
 
@@ -112,6 +112,7 @@
         for a in ([python_executable, local_predict.__file__] + predict_args)
     ]
 
+    log.debug(args)
     proc = subprocess.Popen(
         args,
         stdin=subprocess.PIPE,
@@ -121,9 +122,12 @@
     )
 
     # Pass the instances to the process that actually runs local prediction.
-    for instance in instances:
-        proc.stdin.write((json.dumps(instance) + "\n").encode("utf-8"))
-    proc.stdin.flush()
+    try:
+        for instance in instances:
+            proc.stdin.write((json.dumps(instance) + "\n").encode("utf-8"))
+        proc.stdin.flush()
+    except:
+        pass
 
     # Get the results for the local prediction.
     output, err = proc.communicate()

from cloudml-samples.

kweinmeister avatar kweinmeister commented on May 25, 2024

It looks like this issue is about the AI Platform itself, not sample code in this repo. The best path forward is to contact Google Cloud Support. I will go ahead and close this issue. Please feel free to reopen if you have any questions about the sample code in this repo.

from cloudml-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.