I'm running a julia kernel 1.7.2 in Jupyter notebook on Mac, but when I run the following code I get an error: The kernel appears to have died. It will restart automatically.
I have tried using ] build IJulia but it doesn't work.
This is my code:
Pkg.add("JuMP")
Pkg.add("Cbc")
using JuMP
using Cbc
model = Model(Cbc.Optimizer);
#variable(model, q[1:T] >= 0);
#variable(model, y[1:T] >= 0, Bin);
#variable(model, x[1:T] >= 0);
#objective(model, Min, sum( K*y[t] + h*x[t] for t in 1:T));
#constraint(model,[t = [1]] , x[t] == x0 + q[t] - d[t]);
#constraint(model,[t = 2:T], x[t] == x[t-1] + q[t] - d[t]);
#constraint(model,[t = 1:T], q[t] <= M*y[t]);
I hope you can help. Thank you in advance.
UPDATE:
I tried installing the Cbc in Julia REPL but it doesn't work.
I then ran the script in Julia in the terminal on Mac and got the following error:
Do you know how to fix this?
UPDATE:
I found out that the problem is that I have a new MacBook with an M1 chip. By installing a version of julia meant for Intel or Rosetta, it now works!
Related
I want to run modules of Geopandas in Spyder. Apparently Geopandas is compatible with Sypder 4.2.5, (not with any higher version) and I could run code with this combination. However, in one of my code I had to use "input" command and the problem starts there. Sypder 4.2.5 crashes if I try to run input command. From the internet, I came to know that there was a bug in spyder and it was fixed in Spyder 5.3. Now I have no idea how to fix this problem. If I upgrade Spyder, Geopandas will not work. If I don't upgrade spyder, 'input' will not work.
I was trying to run something like the following code
def Coditions_R3():
print("This is R3")
def Coditions_R4():
print("This is R4")
System = input('Please Enter drone system: \n' )
print(System)
if (System == 'R3'):
Coditions_R3()
elif (System == 'R4'):
Coditions_R4()
Can anyone help? is there any way around to run geopandas with higher Spyder versions? or use something else in place of input?
I have a recurring issue when running even the simplest code using deepface.
For information I run it on python 3.9, with a M1 macbook air on OS Monterey 12.0.1
I can't seem to find any information on how to resolve it, hope anyone can help !
Thank you very much in advance,
Paul
from deepface import DeepFace
result = DeepFace.verify(img1_path = "photo1.jpg", img2_path = "photo2.jpg")
obj = DeepFace.analyze(img_path = "photo1.jpg", actions = ['age', 'gender', 'race', 'emotion'])
I finally found a solution : underlying was an issue with tensor flow. I changed the version I had and replaced it with an M1-compatible version. It worked as intented
We have finetuned our BERT model for text2text generation. It is working fine on the Jupyter notebook. But when I use the same trained model on another server of Ubuntu, then it shows the issue. This is my first post, so please bear with me. The issue I'm facing is that when I generate output on small sentences, it works fine. But on long sentences, it shows the following error:
At most 4 tokens in tensor([ 2, 2, 2, 2, 44763, 44763, 2, 44763]) can be equal to eos_token_id: 2. Make sure tensor([ 2, 2, 2, 2, 44763, 44763, 2, 44763]) are corrected.
My output generation code is:
from simpletransformers.seq2seq import Seq2SeqModel
#logging.basicConfig(level=logging.INFO)
#transformers_logger = logging.getLogger("transformers")
#transformers_logger.setLevel(logging.ERROR)
model = Seq2SeqModel(
encoder_decoder_type="bart", encoder_decoder_name="PATHOFMODEL",use_cuda=False,
)
while True:
original = input("Enter text to paraphrase: ")
to_predict = [original]
preds = model.predict(to_predict)
print("---------------------------------------------------------")
print(original)
print()
print("Predictions >>>")
for pred in preds[0]:
print(pred)
print("---------------------------------------------------------")
print()
You can check your TensorFlow version in your jupyter notebook and verify it on your Ubuntu server. If it's the same, there should be no error.
Firstly uninstall the tensorflow.
pip3 uninstall tensorflow
and then install any old version. Like in the case of version 2.2.0, then install 2.2.0 version using below command.
pip3 install tensorflow==2.2.0
It should work now.
I am trying to solve a LP problem using PuLP on a Google Colab Notebook. To produce a sensitivity report, I want to use the '--ranges filename.txt' option of the GLPK solver. I have installed both PuLP and GLPK as follows:
!pip install pulp
!apt-get install -y -qq glpk-utils
Here is a small example I'm trying to solve:
from pulp import *
prob = LpProblem('Test_Problem',LpMaximize) # Model
x1=LpVariable("x1",0,100) #Variables
x2=LpVariable("x2",0,100)
prob += 5*x1 + 10*x2 # Objective
prob += x1 + 5*x2 <= 500 #Constraints
prob += 2*x1 + 3*x2 <= 200
prob.solve(GLPK(options=[])) # Solve Without '--ranges sensitivity.txt'
print("Status : ", LpStatus[prob.status]) # Output
print("Objective : ", value(prob.objective))
for v in prob.variables():
print(v.name," : ", v.varValue)
This runs fine and gives me the desired output. However, if I use 'options' and change the following line
prob.solve(GLPK(options=['--ranges sensitivity.txt']))
I get this error:
/usr/local/lib/python3.6/dist-packages/pulp/apis/glpk_api.py in actualSolve(self, lp)
91
92 if not os.path.exists(tmpSol):
---> 93 raise PulpSolverError("PuLP: Error while executing "+self.path)
94 status, values = self.readsol(tmpSol)
95 lp.assignVarsVals(values)
PulpSolverError: PuLP: Error while executing glpsol
I have checked that the same code with 'options' works fine on my computer and produces the correct sensitivity.txt file. But for some reason, it is not working on Colab. (I've installed GLPK using conda-forge in my laptop.)
What can I do to solve this?
Thanks!
The options argument to pass to GLPK_CMD need to have no spaces, so:
prob.solve(GLPK(msg=True, options=['--ranges', 'sensitivity.txt']))
Then it works. With your cases, GLPK gave an error without solving the problem saying:
Invalid option '--ranges sensitivity.txt'; try glpsol --help
For the script:
import tensorflow as tf;
class ZeroOutTest(tf.test.TestCase):
def testZeroOut(self):
zero_out_module = tf.load_op_library('/Users/sahilsingla/tensorflow/bazel-bin/tensorflow/core/user_ops/zero_out.so')
with self.test_session():
result = zero_out_module.zero_out([5, 4, 3, 2, 1])
value = result.eval()
self.assertAllEqual(value, [5, 0, 0, 0, 0])
if name == "main":
tf.test.main()
This is the same script given in tensorflow's documentation in "creating a new op", https://www.tensorflow.org/versions/r0.11/how_tos/adding_an_op/index.html
When I run: bazel test tensorflow/python/kernel_tests:zero_out_op_test
I get the error: tensorflow.python.framework.errors.NotFoundError: dlopen(zero_out.so, 6): image not found.
The funny thing is this does load when I do :
python -c "import tensorflow as tf;
zero_out_module = tf.load_op_library('/Users/sahilsingla/tensorflow/bazel-bin/tensorflow/core/user_ops/zero_out.so')"
but doesn't load with bazel test.
Can anyone please suggest what I am doing wrong? How can this error be removed?
For those facing the same problem, I will suggest try building using
bazel build -c opt //tensorflow/g3doc/how_tos/adding_an_op:zero_out_op_kernel_1.so
bazel test //tensorflow/g3doc/how_tos/adding_an_op:zero_out_1_test
instead of how it is given in the tensorflow documentation.
You will get a good idea how to make it work.