当我遇到以下问题时,我正在尝试为cassandra设置用户身份验证.
首先我更新了cassandra.yaml:
authenticator: PasswordAuthenticator
Run Code Online (Sandbox Code Playgroud)
然后创建system_auth键空间,其replication_factor为3,如下所示:
CREATE KEYSPACE system_auth WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3};
Run Code Online (Sandbox Code Playgroud)
然后用命令重新运行cassandra:
bin/cassandra
Run Code Online (Sandbox Code Playgroud)
然后,我继续,并确保修复我的节点(虽然我不知道我是否理解为什么这是重要/必要的):
nodetool repair
Run Code Online (Sandbox Code Playgroud)
即使在完成所有这些步骤之后,cassandra/java也会对我大喊:
Traceback (most recent call last):
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/cqlsh", line 2044, in <module>
main(*read_options(sys.argv[1:], os.environ))
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/cqlsh", line 2030, in main
display_float_precision=options.float_precision)
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/cqlsh", line 480, in __init__
cql_version=cqlver, transport=transport)
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/../lib/cql-internal-only-1.4.1.zip/cql-1.4.1/cql/connection.py", line 143, in connect
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/../lib/cql-internal-only-1.4.1.zip/cql-1.4.1/cql/connection.py", line 59, in __init__
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/../lib/cql-internal-only-1.4.1.zip/cql-1.4.1/cql/thrifteries.py", line 157, in establish_connection
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/../lib/cql-internal-only-1.4.1.zip/cql-1.4.1/cql/cassandra/Cassandra.py", line 465, in login
File "/home/tscobb/Documents/BM/apache-cassandra-2.0.5/bin/../lib/cql-internal-only-1.4.1.zip/cql-1.4.1/cql/cassandra/Cassandra.py", …Run Code Online (Sandbox Code Playgroud) 我想要一种代码量最少的方法,以便我的脚本中的所有内容都在 GPU 中自动运行(或者 pytorch 的标准方式)。就像是:
torch.everything_to_gpu()
Run Code Online (Sandbox Code Playgroud)
然后它就“正常工作”了。我不关心手动将东西放入 GPU 等。我只是希望它自动完成它的事情(有点像张量流那样?)。我确实在 pytorch 论坛中看到了相关问题,但似乎他们没有直接解决我的问题。
现在在我看来(从我经历过的例子来看),可以通过为每个火炬变量/张量指定一个简单类型来完成我想要的事情,如下所示:
dtype = torch.FloatTensor
# dtype = torch.cuda.FloatTensor # Uncomment this to run on GPU
Run Code Online (Sandbox Code Playgroud)
所以只要每个变量/张量都以dtype某种方式进行,例如
Variable(torch.FloatTensor(x).type(dtype), requires_grad=False)
Run Code Online (Sandbox Code Playgroud)
那么我们可以使用该单个变量来控制 GPU 中的内容和不包含的内容。如果存在这样一个命令,我遇到的问题是在使用torch.nn.Modulepackage.json 时遇到的问题。例如当使用
l = torch.nn.Linear(D_in,D_out)
Run Code Online (Sandbox Code Playgroud)
或服装 NN 类(继承自它)。这种情况似乎处理它的最好方法是使用:
torch.nn.Module.cuda(device_id=device_id) # device_id = None is the default
Run Code Online (Sandbox Code Playgroud)
函数/方法。然而,这似乎向我表明,可能还有其他我可能不知道的隐藏功能,以确保一切确实在 GPU 中运行。
因此:是否有一种集中方式来确保所有内容都在某个(最好是自动)分配的 GPU 中运行?
经过反思,我认为让我困惑的一件事是我不明白pytorch如何在GPU上进行计算的模型。例如,我相当确定 MATLAB 的工作方式是,如果至少一件事是在 GPU 上进行的,那么所有进一步的计算都将在 GPU 上进行。所以我想,我想知道,这就是 pytorch 的工作原理吗?如果可能的话,它与 TensorFlow 相比如何?
我试图找到使用 Sympy Variables 创建矩阵(甚至张量,如果你想疯狂,但我不要求的话)的最佳或标准方法。
我将描述我想到的唯一方法。我找到了方法symarray(这里):
A = symarray('a', (3,4))
type(A)
<class 'numpy.ndarray'>
A
array([[a_0_0, a_0_1, a_0_2, a_0_3],
[a_1_0, a_1_1, a_1_2, a_1_3],
[a_2_0, a_2_1, a_2_2, a_2_3]], dtype=object)
Run Code Online (Sandbox Code Playgroud)
我还注意到可以用Matrixsympy 函数包装它:
B = Matrix( symarray('b', (3,4)) )
type(B)
<class 'sympy.matrices.dense.MutableDenseMatrix'>
B
Matrix([
[b_0_0, b_0_1, b_0_2, b_0_3],
[b_1_0, b_1_1, b_1_2, b_1_3],
[b_2_0, b_2_1, b_2_2, b_2_3]])
Run Code Online (Sandbox Code Playgroud)
两者中是否有任何一种是标准的做法?哪种是最好的或者人们通常使用 sympy 变量创建矩阵的方式?
我一直在尝试找出如何启动不同的子流程实例,然后杀死它们然后创建新的实例。父python进程从不执行,只会杀死子进程。我在SO上跟踪了很多链接,但是一旦父python进程结束,我就会不断收到以下消息:
F/Users/Lucifer/miniconda3/envs/rltp/lib/python3.6/subprocess.py:761: ResourceWarning: subprocess 40909 is still running ResourceWarning, source=self)
Run Code Online (Sandbox Code Playgroud)
这似乎很有趣,因为我做到了,ps但是却一无所获:
PID TTY TIME CMD
7070 ttys001 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
7072 ttys001 0:00.61 -bash
17723 ttys002 0:00.06 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp Lucifer
17725 ttys002 0:00.06 -bash
38586 ttys002 0:00.16 sertop --no_init
Run Code Online (Sandbox Code Playgroud)
我只想开始一个过程:
self.serapi = subprocess.Popen(['sertop','--no_init'],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
preexec_fn=os.setsid,shell=True
,)
Run Code Online (Sandbox Code Playgroud)
并杀死它:
os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
Run Code Online (Sandbox Code Playgroud)
上面的代码本质上是从最上面的答案复制的:
但我不确定为什么会收到此消息。我是否成功终止了子进程?我计划启动并杀死其中许多人。
注意我不知道或不需要shell=True。我只是复制了那个,就是我发布的答案/问题的答案。我宁愿没有那个参数。
根据我尝试的答案:
def kill(self):
self.serapi.wait()
#self.serapi.kill()
self.serapi.terminate()
#os.killpg(os.getpgid(self.serapi.pid), signal.SIGTERM)
#self.serapi.wait()
Run Code Online (Sandbox Code Playgroud)
以及上述内容的不同排列方式,但似乎没有任何效果。有什么建议吗?
我想实现一个 ResNet 网络(或者更确切地说,残差块),但我真的希望它采用顺序网络形式。
我所说的顺序网络形式如下:
## mdl5, from cifar10 tutorial
mdl5 = nn.Sequential(OrderedDict([
('pool1', nn.MaxPool2d(2, 2)),
('relu1', nn.ReLU()),
('conv1', nn.Conv2d(3, 6, 5)),
('pool1', nn.MaxPool2d(2, 2)),
('relu2', nn.ReLU()),
('conv2', nn.Conv2d(6, 16, 5)),
('relu2', nn.ReLU()),
('Flatten', Flatten()),
('fc1', nn.Linear(1024, 120)), # figure out equation properly
('relu4', nn.ReLU()),
('fc2', nn.Linear(120, 84)),
('relu5', nn.ReLU()),
('fc3', nn.Linear(84, 10))
]))
Run Code Online (Sandbox Code Playgroud)
但当然,NN 乐高积木是“ResNet”。
我知道等式是这样的:
但我不确定如何在 Pytorch AND Sequential 中做到这一点。顺序对我来说很关键!
交叉发布:
machine-learning neural-network deep-learning conv-neural-network pytorch
我正在使用 Visual Studio 代码和 jupyter 功能,我想在不转到下一个单元格或创建新单元格的情况下运行当前单元格。只需运行当前单元格并将光标保持在那里(不要自动移动到下一个或创建一个)。
我试过:
Command + Enter
和
alt + Enter
但两者似乎都让我移动到下一个单元格。有人知道怎么修这个东西吗?我只想运行当前单元格并留在其中。而已。
看到建议为“相似”的问题,似乎大多数人想要的与我想要的相反。我想要的是 Vs-code 的调试器在错误点停止,即使在 try catch 中(通常会这样做)。
但是,当在像这样的 try catch 中时,它所做的并不是停止:
import traceback
try:
main() # has bugs I'm trying to debug
except Exception as e:
send_email(traceback.format_exc())
send_email(e)
Run Code Online (Sandbox Code Playgroud)
我知道这可能是一件奇怪的事情,并且 vs-code 的调试器可能运行正确(因为我的代码告诉它如何处理异常!)但我有一些错误,我想调试而不是捕捉。事实上,我的外部 try catch 就在那里,因为我正在使用一个集群,当有任何错误时,它会向我发送电子邮件并告诉我有关它们的信息。否则我就不会在我的主要代码周围有一个 try catch 。
当我实际调试时,有没有办法告诉 vs-code 忽略我的尝试捕获?
我在写这篇文章时的一个想法是改变我捕捉到的异常类型……虽然在调试期间我希望它总是停止,而在不调试时我希望它永远不会停止并向我发送一封包含漏洞。
有任何想法吗?
新错误:
Exception has occurred: TypeError
catching classes that do not inherit from BaseException is not allowed
Run Code Online (Sandbox Code Playgroud)
使用我的EmptyException答案时:
class EmptyError(Exception):
def __init__(self):
pass
Run Code Online (Sandbox Code Playgroud) 有时我发现很难使用 Isabelle,因为我无法像在正常编程中那样使用“打印命令”。
例如,我想看看什么?thesis. 具体语义书说:
未知 ?thesis 隐含地与引理或 show 陈述的任何目标相匹配。下面是一个典型的例子:
我的愚蠢示例 FOL 证明是:
lemma
assumes "(? x. ? y. x ? y)"
shows "(?x. ? y. y ? x)"
proof (rule allI)
show ?thesis
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
proof (state)
goal (1 subgoal):
1. ?x. ?y. y ? x
Failed to refine any pending goal
Local statement fails to refine any pending goal
Failed attempt to solve goal by exported rule:
?x. ?y. y ? x
Run Code Online (Sandbox Code Playgroud)
但我知道为什么。
我期望
?thesis === ?x. ?y. …Run Code Online (Sandbox Code Playgroud) 我发现 PyCharm 停止处理我的所有异常,甚至是我在try except块中处理的异常。我不希望它在那里中断 - 我正在处理并且可能期待一个错误。但我确实希望它停止并暂停执行所有其他异常(例如,以便我拥有程序状态并对其进行调试)。
如何做到这一点?
\n我尝试进入 python 异常断点选项,但没有看到像“仅在未处理的异常上中断”这样的选项,例如:
\n注意这是我当前的状态,注意它是如何在我的 try 块中停止的......:(
\n\n\n我试过:
\nIn your link here intellij-support.jetbrains.com/hc/en-us/community/posts/\xe2\x80\xa6 the poster Okke said they solved this issue adding --pdb to the \'addition arguments\', which someone later said they probably meant interpreter options.\nRun Code Online (Sandbox Code Playgroud)\n但没有工作并出现错误:
\n/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python --pdb /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support=auto --client 127.0.0.1 --port 58378 --file /Users/brandomiranda/ultimate-utils/tutorials_for_myself/try_catch_pycharm_issues/try_catch_with_pickle.py\nunknown option --pdb\nusage: /Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python …Run Code Online (Sandbox Code Playgroud) 我正在使用的项目之一在 it/s .gitmodules 文件中:
\n(iit_synthesis) brando9~/proverbot9001 $ cat .gitmodules | grep \'metalib\'\n[submodule "deps/metalib"]\n path = deps/metalib\n url = git@github.com:plclub/metalib.git\nRun Code Online (Sandbox Code Playgroud)\n\n[submodule "coq-projects/metalib"]\n path = coq-projects/metalib\n url = git@github.com:plclub/metalib.git\nRun Code Online (Sandbox Code Playgroud)\n当我通过命令行执行此操作时,由于 gitignore 文件,它不允许我这样做:
\n(iit_synthesis) brandomiranda~/proverbot9001 \xe2\x9d\xaf git submodule add --name coq-projects/metalib https://git@github.com:plclub/metalib.git coq-projects/metalib\n\nThe following paths are ignored by one of your .gitignore files:\ncoq-projects\ncoq-projects/metalib\nhint: Use -f if you really want to add them.\nhint: Turn this message off by running\nhint: "git config advice.addIgnoredFile false"\nRun Code Online (Sandbox Code Playgroud)\n我打算手动修改它,但感觉很脏,很奇怪。然后我将强制它更新:
\ngit …Run Code Online (Sandbox Code Playgroud)